mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-18 18:45:45 -04:00
HostDisplay: Support refresh rate queries on all platforms except Mac
This commit is contained in:
@ -520,6 +520,8 @@ bool CommonHostInterface::CreateHostDisplayResources()
|
||||
|
||||
const float framebuffer_scale = m_display->GetWindowScale();
|
||||
ImGui::GetIO().DisplayFramebufferScale = ImVec2(framebuffer_scale, framebuffer_scale);
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_display->GetWindowWidth());
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_display->GetWindowHeight());
|
||||
ImGui::GetStyle() = ImGuiStyle();
|
||||
ImGui::StyleColorsDarker();
|
||||
ImGui::GetStyle().ScaleAllSizes(framebuffer_scale);
|
||||
@ -566,8 +568,15 @@ void CommonHostInterface::ReleaseHostDisplayResources()
|
||||
m_logo_texture.reset();
|
||||
}
|
||||
|
||||
void CommonHostInterface::OnHostDisplayResized(u32 new_width, u32 new_height, float new_scale)
|
||||
void CommonHostInterface::OnHostDisplayResized()
|
||||
{
|
||||
const u32 new_width = m_display ? std::max<u32>(m_display->GetWindowWidth(), 1) : 0;
|
||||
const u32 new_height = m_display ? std::max<u32>(m_display->GetWindowHeight(), 1) : 0;
|
||||
const float new_scale = m_display ? m_display->GetWindowScale() : 1.0f;
|
||||
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(new_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(new_height);
|
||||
|
||||
if (new_scale != ImGui::GetIO().DisplayFramebufferScale.x)
|
||||
{
|
||||
ImGui::GetIO().DisplayFramebufferScale = ImVec2(new_scale, new_scale);
|
||||
@ -1792,7 +1801,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
||||
if (pressed)
|
||||
SetTurboEnabled(!m_turbo_enabled);
|
||||
});
|
||||
#ifndef ANDROID
|
||||
#ifndef __ANDROID__
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ToggleFullscreen"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Toggle Fullscreen")), [this](bool pressed) {
|
||||
if (pressed)
|
||||
|
@ -414,7 +414,7 @@ protected:
|
||||
|
||||
bool CreateHostDisplayResources();
|
||||
void ReleaseHostDisplayResources();
|
||||
void OnHostDisplayResized(u32 new_width, u32 new_height, float new_scale);
|
||||
void OnHostDisplayResized();
|
||||
|
||||
virtual void DrawImGuiWindows();
|
||||
|
||||
|
@ -473,10 +473,17 @@ bool D3D11HostDisplay::CreateSwapChainRTV()
|
||||
m_window_info.surface_width = backbuffer_desc.Width;
|
||||
m_window_info.surface_height = backbuffer_desc.Height;
|
||||
|
||||
if (ImGui::GetCurrentContext())
|
||||
BOOL fullscreen = FALSE;
|
||||
DXGI_SWAP_CHAIN_DESC desc;
|
||||
if (SUCCEEDED(m_swap_chain->GetFullscreenState(&fullscreen, nullptr)) && fullscreen &&
|
||||
SUCCEEDED(m_swap_chain->GetDesc(&desc)))
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(backbuffer_desc.Width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(backbuffer_desc.Height);
|
||||
m_window_info.surface_refresh_rate = static_cast<float>(desc.BufferDesc.RefreshRate.Numerator) /
|
||||
static_cast<float>(desc.BufferDesc.RefreshRate.Denominator);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_window_info.surface_refresh_rate = 0.0f;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -664,8 +671,6 @@ void D3D11HostDisplay::DestroyResources()
|
||||
|
||||
bool D3D11HostDisplay::CreateImGuiContext()
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
return ImGui_ImplDX11_Init(m_device.Get(), m_context.Get());
|
||||
}
|
||||
|
||||
|
@ -384,9 +384,7 @@ bool OpenGLHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_vie
|
||||
return false;
|
||||
}
|
||||
|
||||
m_window_info = wi;
|
||||
m_window_info.surface_width = m_gl_context->GetSurfaceWidth();
|
||||
m_window_info.surface_height = m_gl_context->GetSurfaceHeight();
|
||||
m_window_info = m_gl_context->GetWindowInfo();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -467,16 +465,7 @@ bool OpenGLHostDisplay::ChangeRenderWindow(const WindowInfo& new_wi)
|
||||
return false;
|
||||
}
|
||||
|
||||
m_window_info = new_wi;
|
||||
m_window_info.surface_width = m_gl_context->GetSurfaceWidth();
|
||||
m_window_info.surface_height = m_gl_context->GetSurfaceHeight();
|
||||
|
||||
if (ImGui::GetCurrentContext())
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
}
|
||||
|
||||
m_window_info = m_gl_context->GetWindowInfo();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -486,14 +475,7 @@ void OpenGLHostDisplay::ResizeRenderWindow(s32 new_window_width, s32 new_window_
|
||||
return;
|
||||
|
||||
m_gl_context->ResizeSurface(static_cast<u32>(new_window_width), static_cast<u32>(new_window_height));
|
||||
m_window_info.surface_width = m_gl_context->GetSurfaceWidth();
|
||||
m_window_info.surface_height = m_gl_context->GetSurfaceHeight();
|
||||
|
||||
if (ImGui::GetCurrentContext())
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
}
|
||||
m_window_info = m_gl_context->GetWindowInfo();
|
||||
}
|
||||
|
||||
bool OpenGLHostDisplay::SupportsFullscreen() const
|
||||
@ -539,8 +521,6 @@ void OpenGLHostDisplay::DestroyRenderSurface()
|
||||
|
||||
bool OpenGLHostDisplay::CreateImGuiContext()
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
return ImGui_ImplOpenGL3_Init(GetGLSLVersionString());
|
||||
}
|
||||
|
||||
|
@ -76,12 +76,13 @@ bool VulkanHostDisplay::ChangeRenderWindow(const WindowInfo& new_wi)
|
||||
{
|
||||
g_vulkan_context->ExecuteCommandBuffer(true);
|
||||
m_swap_chain.reset();
|
||||
m_window_info = new_wi;
|
||||
return true;
|
||||
}
|
||||
|
||||
WindowInfo wi_copy(new_wi);
|
||||
VkSurfaceKHR surface = Vulkan::SwapChain::CreateVulkanSurface(g_vulkan_context->GetVulkanInstance(),
|
||||
g_vulkan_context->GetPhysicalDevice(), wi_copy);
|
||||
g_vulkan_context->GetPhysicalDevice(), &wi_copy);
|
||||
if (surface == VK_NULL_HANDLE)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create new surface for swap chain");
|
||||
@ -95,16 +96,7 @@ bool VulkanHostDisplay::ChangeRenderWindow(const WindowInfo& new_wi)
|
||||
return false;
|
||||
}
|
||||
|
||||
m_window_info = wi_copy;
|
||||
m_window_info.surface_width = m_swap_chain->GetWidth();
|
||||
m_window_info.surface_height = m_swap_chain->GetHeight();
|
||||
|
||||
if (ImGui::GetCurrentContext())
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
}
|
||||
|
||||
m_window_info = m_swap_chain->GetWindowInfo();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -115,14 +107,7 @@ void VulkanHostDisplay::ResizeRenderWindow(s32 new_window_width, s32 new_window_
|
||||
if (!m_swap_chain->ResizeSwapChain(new_window_width, new_window_height))
|
||||
Panic("Failed to resize swap chain");
|
||||
|
||||
m_window_info.surface_width = m_swap_chain->GetWidth();
|
||||
m_window_info.surface_height = m_swap_chain->GetHeight();
|
||||
|
||||
if (ImGui::GetCurrentContext())
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
}
|
||||
m_window_info = m_swap_chain->GetWindowInfo();
|
||||
}
|
||||
|
||||
bool VulkanHostDisplay::SupportsFullscreen() const
|
||||
@ -320,19 +305,15 @@ void VulkanHostDisplay::SetVSync(bool enabled)
|
||||
bool VulkanHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device,
|
||||
bool threaded_presentation)
|
||||
{
|
||||
if (!Vulkan::Context::Create(adapter_name, &wi, &m_swap_chain, threaded_presentation, debug_device, false))
|
||||
WindowInfo local_wi(wi);
|
||||
if (!Vulkan::Context::Create(adapter_name, &local_wi, &m_swap_chain, threaded_presentation, debug_device, false))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create Vulkan context");
|
||||
m_window_info = {};
|
||||
return false;
|
||||
}
|
||||
|
||||
m_window_info = wi;
|
||||
if (m_swap_chain)
|
||||
{
|
||||
m_window_info.surface_width = m_swap_chain->GetWidth();
|
||||
m_window_info.surface_height = m_swap_chain->GetHeight();
|
||||
}
|
||||
|
||||
m_window_info = m_swap_chain ? m_swap_chain->GetWindowInfo() : local_wi;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -526,9 +507,6 @@ void VulkanHostDisplay::DestroyResources()
|
||||
|
||||
bool VulkanHostDisplay::CreateImGuiContext()
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
|
||||
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
|
||||
|
||||
ImGui_ImplVulkan_InitInfo vii = {};
|
||||
vii.Instance = g_vulkan_context->GetVulkanInstance();
|
||||
vii.PhysicalDevice = g_vulkan_context->GetPhysicalDevice();
|
||||
|
Reference in New Issue
Block a user