mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 09:35:40 +00:00
HostDisplay: Add stretch option
This commit is contained in:
parent
f18babb97e
commit
e17d37b8bc
|
@ -212,4 +212,6 @@
|
||||||
<string name="save_state_info_quick_save">Quick Save</string>
|
<string name="save_state_info_quick_save">Quick Save</string>
|
||||||
<string name="settings_osd_show_show_resolution">Show Resolution</string>
|
<string name="settings_osd_show_show_resolution">Show Resolution</string>
|
||||||
<string name="settings_summary_osd_show_resolution">Shows the resolution the game is rendering at in the top-right corner of the display.</string>
|
<string name="settings_summary_osd_show_resolution">Shows the resolution the game is rendering at in the top-right corner of the display.</string>
|
||||||
|
<string name="settings_summary_display_stretch">Stretches the active display to fill the screen.</string>
|
||||||
|
<string name="settings_display_stretch">Stretch To Fill</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -43,18 +43,28 @@
|
||||||
app:useSimpleSummaryProvider="true"
|
app:useSimpleSummaryProvider="true"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
app:key="Display/IntegerScaling"
|
||||||
|
app:title="@string/settings_integer_upscaling"
|
||||||
|
app:defaultValue="false"
|
||||||
|
app:disableDependentsState="true"
|
||||||
|
app:summary="@string/settings_summary_integer_upscaling"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
app:key="Display/LinearFiltering"
|
app:key="Display/LinearFiltering"
|
||||||
app:title="@string/settings_linear_upscaling"
|
app:title="@string/settings_linear_upscaling"
|
||||||
app:defaultValue="true"
|
app:defaultValue="true"
|
||||||
|
app:dependency="Display/IntegerScaling"
|
||||||
app:summary="@string/settings_summary_linear_upscaling"
|
app:summary="@string/settings_summary_linear_upscaling"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
app:key="Display/IntegerScaling"
|
app:key="Display/Stretch"
|
||||||
app:title="@string/settings_integer_upscaling"
|
app:title="@string/settings_display_stretch"
|
||||||
app:defaultValue="false"
|
app:defaultValue="false"
|
||||||
app:summary="@string/settings_summary_integer_upscaling"
|
app:dependency="Display/IntegerScaling"
|
||||||
|
app:summary="@string/settings_summary_display_stretch"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
|
@ -63,6 +73,7 @@
|
||||||
app:defaultValue="true"
|
app:defaultValue="true"
|
||||||
app:summary="@string/settings_summary_osd_show_messages"
|
app:summary="@string/settings_summary_osd_show_messages"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
app:key="Display/ShowSpeed"
|
app:key="Display/ShowSpeed"
|
||||||
app:title="@string/settings_osd_show_speed"
|
app:title="@string/settings_osd_show_speed"
|
||||||
|
|
|
@ -148,9 +148,11 @@ void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, float*
|
||||||
float* out_top_padding, float* out_scale, float* out_x_scale,
|
float* out_top_padding, float* out_scale, float* out_x_scale,
|
||||||
bool apply_aspect_ratio /* = true */) const
|
bool apply_aspect_ratio /* = true */) const
|
||||||
{
|
{
|
||||||
|
const float window_ratio = static_cast<float>(window_width) / static_cast<float>(window_height);
|
||||||
|
const float display_aspect_ratio = m_display_stretch ? window_ratio : m_display_aspect_ratio;
|
||||||
const float x_scale =
|
const float x_scale =
|
||||||
apply_aspect_ratio ?
|
apply_aspect_ratio ?
|
||||||
(m_display_aspect_ratio / (static_cast<float>(m_display_width) / static_cast<float>(m_display_height))) :
|
(display_aspect_ratio / (static_cast<float>(m_display_width) / static_cast<float>(m_display_height))) :
|
||||||
1.0f;
|
1.0f;
|
||||||
const float display_width = static_cast<float>(m_display_width) * x_scale;
|
const float display_width = static_cast<float>(m_display_width) * x_scale;
|
||||||
const float display_height = static_cast<float>(m_display_height);
|
const float display_height = static_cast<float>(m_display_height);
|
||||||
|
@ -162,8 +164,6 @@ void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, float*
|
||||||
*out_x_scale = x_scale;
|
*out_x_scale = x_scale;
|
||||||
|
|
||||||
// now fit it within the window
|
// now fit it within the window
|
||||||
const float window_ratio = static_cast<float>(window_width) / static_cast<float>(window_height);
|
|
||||||
|
|
||||||
float scale;
|
float scale;
|
||||||
if ((display_width / display_height) >= window_ratio)
|
if ((display_width / display_height) >= window_ratio)
|
||||||
{
|
{
|
||||||
|
|
|
@ -196,6 +196,7 @@ public:
|
||||||
void SetDisplayTopMargin(s32 height) { m_display_top_margin = height; }
|
void SetDisplayTopMargin(s32 height) { m_display_top_margin = height; }
|
||||||
void SetDisplayIntegerScaling(bool enabled) { m_display_integer_scaling = enabled; }
|
void SetDisplayIntegerScaling(bool enabled) { m_display_integer_scaling = enabled; }
|
||||||
void SetDisplayAlignment(Alignment alignment) { m_display_alignment = alignment; }
|
void SetDisplayAlignment(Alignment alignment) { m_display_alignment = alignment; }
|
||||||
|
void SetDisplayStretch(bool stretch) { m_display_stretch = stretch; }
|
||||||
|
|
||||||
/// Sets the software cursor to the specified texture. Ownership of the texture is transferred.
|
/// Sets the software cursor to the specified texture. Ownership of the texture is transferred.
|
||||||
void SetSoftwareCursor(std::unique_ptr<HostDisplayTexture> texture, float scale = 1.0f);
|
void SetSoftwareCursor(std::unique_ptr<HostDisplayTexture> texture, float scale = 1.0f);
|
||||||
|
@ -276,4 +277,5 @@ protected:
|
||||||
bool m_display_linear_filtering = false;
|
bool m_display_linear_filtering = false;
|
||||||
bool m_display_changed = false;
|
bool m_display_changed = false;
|
||||||
bool m_display_integer_scaling = false;
|
bool m_display_integer_scaling = false;
|
||||||
|
bool m_display_stretch = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -109,6 +109,7 @@ bool HostInterface::BootSystem(const SystemBootParameters& parameters)
|
||||||
// set host display settings
|
// set host display settings
|
||||||
m_display->SetDisplayLinearFiltering(g_settings.display_linear_filtering);
|
m_display->SetDisplayLinearFiltering(g_settings.display_linear_filtering);
|
||||||
m_display->SetDisplayIntegerScaling(g_settings.display_integer_scaling);
|
m_display->SetDisplayIntegerScaling(g_settings.display_integer_scaling);
|
||||||
|
m_display->SetDisplayStretch(g_settings.display_stretch);
|
||||||
|
|
||||||
// create the audio stream. this will never fail, since we'll just fall back to null
|
// create the audio stream. this will never fail, since we'll just fall back to null
|
||||||
CreateAudioStream();
|
CreateAudioStream();
|
||||||
|
@ -545,6 +546,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
|
||||||
si.SetBoolValue("Display", "Force4_3For24Bit", false);
|
si.SetBoolValue("Display", "Force4_3For24Bit", false);
|
||||||
si.SetBoolValue("Display", "LinearFiltering", true);
|
si.SetBoolValue("Display", "LinearFiltering", true);
|
||||||
si.SetBoolValue("Display", "IntegerScaling", false);
|
si.SetBoolValue("Display", "IntegerScaling", false);
|
||||||
|
si.SetBoolValue("Display", "Stretch", false);
|
||||||
si.SetBoolValue("Display", "PostProcessing", false);
|
si.SetBoolValue("Display", "PostProcessing", false);
|
||||||
si.SetBoolValue("Display", "ShowOSDMessages", true);
|
si.SetBoolValue("Display", "ShowOSDMessages", true);
|
||||||
si.SetBoolValue("Display", "ShowFPS", false);
|
si.SetBoolValue("Display", "ShowFPS", false);
|
||||||
|
@ -593,8 +595,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
|
||||||
si.SetStringValue("MemoryCards", "Card2Path", "memcards" FS_OSPATH_SEPARATOR_STR "shared_card_2.mcd");
|
si.SetStringValue("MemoryCards", "Card2Path", "memcards" FS_OSPATH_SEPARATOR_STR "shared_card_2.mcd");
|
||||||
si.SetBoolValue("MemoryCards", "UsePlaylistTitle", true);
|
si.SetBoolValue("MemoryCards", "UsePlaylistTitle", true);
|
||||||
|
|
||||||
si.SetStringValue("ControllerPorts", "MultitapMode",
|
si.SetStringValue("ControllerPorts", "MultitapMode", Settings::GetMultitapModeName(Settings::DEFAULT_MULTITAP_MODE));
|
||||||
Settings::GetMultitapModeName(Settings::DEFAULT_MULTITAP_MODE));
|
|
||||||
|
|
||||||
si.SetStringValue("Logging", "LogLevel", Settings::GetLogLevelName(Settings::DEFAULT_LOG_LEVEL));
|
si.SetStringValue("Logging", "LogLevel", Settings::GetLogLevelName(Settings::DEFAULT_LOG_LEVEL));
|
||||||
si.SetStringValue("Logging", "LogFilter", "");
|
si.SetStringValue("Logging", "LogFilter", "");
|
||||||
|
@ -655,6 +656,12 @@ void HostInterface::FixIncompatibleSettings(bool display_osd_messages)
|
||||||
g_settings.display_linear_filtering = false;
|
g_settings.display_linear_filtering = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_settings.display_stretch && g_settings.display_linear_filtering)
|
||||||
|
{
|
||||||
|
Log_WarningPrintf("Disabling stretch due to integer upscaling.");
|
||||||
|
g_settings.display_stretch = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_settings.gpu_pgxp_enable)
|
if (g_settings.gpu_pgxp_enable)
|
||||||
{
|
{
|
||||||
if (g_settings.gpu_renderer == GPURenderer::Software)
|
if (g_settings.gpu_renderer == GPURenderer::Software)
|
||||||
|
@ -884,11 +891,17 @@ 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 && g_settings.display_linear_filtering != old_settings.display_linear_filtering)
|
if (m_display)
|
||||||
m_display->SetDisplayLinearFiltering(g_settings.display_linear_filtering);
|
{
|
||||||
|
if (g_settings.display_linear_filtering != old_settings.display_linear_filtering)
|
||||||
|
m_display->SetDisplayLinearFiltering(g_settings.display_linear_filtering);
|
||||||
|
|
||||||
if (m_display && g_settings.display_integer_scaling != old_settings.display_integer_scaling)
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostInterface::SetUserDirectoryToProgramDirectory()
|
void HostInterface::SetUserDirectoryToProgramDirectory()
|
||||||
|
|
|
@ -214,6 +214,7 @@ void Settings::Load(SettingsInterface& si)
|
||||||
display_line_end_offset = static_cast<s8>(si.GetIntValue("Display", "LineEndOffset", 0));
|
display_line_end_offset = static_cast<s8>(si.GetIntValue("Display", "LineEndOffset", 0));
|
||||||
display_linear_filtering = si.GetBoolValue("Display", "LinearFiltering", true);
|
display_linear_filtering = si.GetBoolValue("Display", "LinearFiltering", true);
|
||||||
display_integer_scaling = si.GetBoolValue("Display", "IntegerScaling", false);
|
display_integer_scaling = si.GetBoolValue("Display", "IntegerScaling", false);
|
||||||
|
display_stretch = si.GetBoolValue("Display", "Stretch", false);
|
||||||
display_post_processing = si.GetBoolValue("Display", "PostProcessing", false);
|
display_post_processing = si.GetBoolValue("Display", "PostProcessing", false);
|
||||||
display_show_osd_messages = si.GetBoolValue("Display", "ShowOSDMessages", true);
|
display_show_osd_messages = si.GetBoolValue("Display", "ShowOSDMessages", true);
|
||||||
display_show_fps = si.GetBoolValue("Display", "ShowFPS", false);
|
display_show_fps = si.GetBoolValue("Display", "ShowFPS", false);
|
||||||
|
@ -382,6 +383,7 @@ void Settings::Save(SettingsInterface& si) const
|
||||||
si.SetStringValue("Display", "AspectRatio", GetDisplayAspectRatioName(display_aspect_ratio));
|
si.SetStringValue("Display", "AspectRatio", GetDisplayAspectRatioName(display_aspect_ratio));
|
||||||
si.SetBoolValue("Display", "LinearFiltering", display_linear_filtering);
|
si.SetBoolValue("Display", "LinearFiltering", display_linear_filtering);
|
||||||
si.SetBoolValue("Display", "IntegerScaling", display_integer_scaling);
|
si.SetBoolValue("Display", "IntegerScaling", display_integer_scaling);
|
||||||
|
si.SetBoolValue("Display", "Stretch", display_stretch);
|
||||||
si.SetBoolValue("Display", "PostProcessing", display_post_processing);
|
si.SetBoolValue("Display", "PostProcessing", display_post_processing);
|
||||||
si.SetBoolValue("Display", "ShowOSDMessages", display_show_osd_messages);
|
si.SetBoolValue("Display", "ShowOSDMessages", display_show_osd_messages);
|
||||||
si.SetBoolValue("Display", "ShowFPS", display_show_fps);
|
si.SetBoolValue("Display", "ShowFPS", display_show_fps);
|
||||||
|
|
|
@ -134,6 +134,7 @@ struct Settings
|
||||||
bool gpu_24bit_chroma_smoothing = false;
|
bool gpu_24bit_chroma_smoothing = false;
|
||||||
bool display_linear_filtering = true;
|
bool display_linear_filtering = true;
|
||||||
bool display_integer_scaling = false;
|
bool display_integer_scaling = false;
|
||||||
|
bool display_stretch = false;
|
||||||
bool display_post_processing = false;
|
bool display_post_processing = false;
|
||||||
bool display_show_osd_messages = false;
|
bool display_show_osd_messages = false;
|
||||||
bool display_show_fps = false;
|
bool display_show_fps = false;
|
||||||
|
|
|
@ -35,6 +35,8 @@ DisplaySettingsWidget::DisplaySettingsWidget(QtHostInterface* host_interface, QW
|
||||||
"LinearFiltering");
|
"LinearFiltering");
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.displayIntegerScaling, "Display",
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.displayIntegerScaling, "Display",
|
||||||
"IntegerScaling");
|
"IntegerScaling");
|
||||||
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.displayStretch, "Display",
|
||||||
|
"Stretch");
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.vsync, "Display", "VSync");
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.vsync, "Display", "VSync");
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.displayAllFrames, "Display", "DisplayAllFrames",
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.displayAllFrames, "Display", "DisplayAllFrames",
|
||||||
false);
|
false);
|
||||||
|
@ -99,6 +101,9 @@ DisplaySettingsWidget::DisplaySettingsWidget(QtHostInterface* host_interface, QW
|
||||||
m_ui.displayIntegerScaling, tr("Integer Upscaling"), tr("Unchecked"),
|
m_ui.displayIntegerScaling, tr("Integer Upscaling"), tr("Unchecked"),
|
||||||
tr("Adds padding to the display area to ensure that the ratio between pixels on the host to "
|
tr("Adds padding to the display area to ensure that the ratio between pixels on the host to "
|
||||||
"pixels in the console is an integer number. <br>May result in a sharper image in some 2D games."));
|
"pixels in the console is an integer number. <br>May result in a sharper image in some 2D games."));
|
||||||
|
dialog->registerWidgetHelp(
|
||||||
|
m_ui.displayIntegerScaling, tr("Stretch To Fill"), tr("Unchecked"),
|
||||||
|
tr("Fills the window with the active display area, regardless of the aspect ratio."));
|
||||||
dialog->registerWidgetHelp(
|
dialog->registerWidgetHelp(
|
||||||
m_ui.vsync, tr("VSync"), tr("Checked"),
|
m_ui.vsync, tr("VSync"), tr("Checked"),
|
||||||
tr("Enable this option to match DuckStation's refresh rate with your current monitor or screen. "
|
tr("Enable this option to match DuckStation's refresh rate with your current monitor or screen. "
|
||||||
|
@ -268,4 +273,5 @@ void DisplaySettingsWidget::onGPUFullscreenModeIndexChanged()
|
||||||
void DisplaySettingsWidget::onIntegerFilteringChanged()
|
void DisplaySettingsWidget::onIntegerFilteringChanged()
|
||||||
{
|
{
|
||||||
m_ui.displayLinearFiltering->setEnabled(!m_ui.displayIntegerScaling->isChecked());
|
m_ui.displayLinearFiltering->setEnabled(!m_ui.displayIntegerScaling->isChecked());
|
||||||
|
m_ui.displayStretch->setEnabled(!m_ui.displayIntegerScaling->isChecked());
|
||||||
}
|
}
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>448</width>
|
<width>485</width>
|
||||||
<height>430</height>
|
<height>525</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -134,18 +134,25 @@
|
||||||
<widget class="QComboBox" name="gpuDownsampleMode"/>
|
<widget class="QComboBox" name="gpuDownsampleMode"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QCheckBox" name="displayLinearFiltering">
|
<widget class="QCheckBox" name="displayIntegerScaling">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Linear Upscaling</string>
|
<string>Integer Upscaling</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QCheckBox" name="displayIntegerScaling">
|
<widget class="QCheckBox" name="displayStretch">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Integer Upscaling</string>
|
<string>Stretch To Fill</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="displayLinearFiltering">
|
||||||
|
<property name="text">
|
||||||
|
<string>Linear Upscaling</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -447,11 +447,11 @@ void QtHostInterface::onDisplayWindowMouseWheelEvent(const QPoint& delta_angle)
|
||||||
|
|
||||||
void QtHostInterface::onDisplayWindowResized(int width, int height)
|
void QtHostInterface::onDisplayWindowResized(int width, int height)
|
||||||
{
|
{
|
||||||
Log_WarningPrintf("resize %dx%d", width, height);
|
|
||||||
// this can be null if it was destroyed and the main thread is late catching up
|
// this can be null if it was destroyed and the main thread is late catching up
|
||||||
if (!m_display)
|
if (!m_display)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Log_DevPrintf("Display window resized to %dx%d", width, height);
|
||||||
m_display->ResizeRenderWindow(width, height);
|
m_display->ResizeRenderWindow(width, height);
|
||||||
OnHostDisplayResized(width, height, m_display->GetWindowScale());
|
OnHostDisplayResized(width, height, m_display->GetWindowScale());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue