CommonHostInterface: Add resize window to scale functions

This commit is contained in:
Connor McLaughlin
2020-11-18 23:14:25 +10:00
parent 0726ad1275
commit e4d2b7331b
5 changed files with 71 additions and 0 deletions

View File

@ -2534,6 +2534,28 @@ bool CommonHostInterface::ParseFullscreenMode(const std::string_view& mode, u32*
return false;
}
bool CommonHostInterface::RequestRenderWindowSize(s32 new_window_width, s32 new_window_height)
{
return false;
}
bool CommonHostInterface::RequestRenderWindowScale(float scale)
{
if (!System::IsValid() || scale == 0)
return false;
const float y_scale =
(static_cast<float>(m_display->GetDisplayWidth()) / static_cast<float>(m_display->GetDisplayHeight())) /
m_display->GetDisplayAspectRatio();
const u32 requested_width =
std::max<u32>(static_cast<u32>(std::ceil(static_cast<float>(m_display->GetDisplayWidth()) * scale)), 1);
const u32 requested_height =
std::max<u32>(static_cast<u32>(std::ceil(static_cast<float>(m_display->GetDisplayHeight()) * y_scale * scale)), 1);
return RequestRenderWindowSize(static_cast<s32>(requested_width), static_cast<s32>(requested_height));
}
#ifdef WITH_DISCORD_PRESENCE
void CommonHostInterface::SetDiscordPresenceEnabled(bool enabled)

View File

@ -183,6 +183,12 @@ public:
/// Returns true if fast forwarding is currently active.
bool IsFastForwardEnabled() const { return m_fast_forward_enabled; }
/// Requests the specified size for the render window. Not guaranteed to succeed (e.g. if in fullscreen).
virtual bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height);
/// Requests a resize to a multiple of the render window size.
bool RequestRenderWindowScale(float scale);
protected:
enum : u32
{