HostDisplay: Support refresh rate queries on all platforms except Mac
This commit is contained in:
@ -25,11 +25,6 @@
|
||||
#include <stdlib.h>
|
||||
Log_SetChannel(HostInterface);
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "common/windows_headers.h"
|
||||
#include <dwmapi.h>
|
||||
#endif
|
||||
|
||||
HostInterface* g_host_interface;
|
||||
|
||||
HostInterface::HostInterface()
|
||||
@ -1065,43 +1060,6 @@ std::string HostInterface::TranslateStdString(const char* context, const char* s
|
||||
return result;
|
||||
}
|
||||
|
||||
bool HostInterface::GetMainDisplayRefreshRate(float* refresh_rate)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
static HMODULE dwm_module = nullptr;
|
||||
static HRESULT(STDAPICALLTYPE * get_timing_info)(HWND hwnd, DWM_TIMING_INFO * pTimingInfo) = nullptr;
|
||||
static bool load_tried = false;
|
||||
if (!load_tried)
|
||||
{
|
||||
load_tried = true;
|
||||
dwm_module = LoadLibrary("dwmapi.dll");
|
||||
if (dwm_module)
|
||||
{
|
||||
std::atexit([]() {
|
||||
FreeLibrary(dwm_module);
|
||||
dwm_module = nullptr;
|
||||
});
|
||||
get_timing_info =
|
||||
reinterpret_cast<decltype(get_timing_info)>(GetProcAddress(dwm_module, "DwmGetCompositionTimingInfo"));
|
||||
}
|
||||
}
|
||||
|
||||
DWM_TIMING_INFO ti = {};
|
||||
ti.cbSize = sizeof(ti);
|
||||
HRESULT hr = get_timing_info(nullptr, &ti);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
if (ti.rateRefresh.uiNumerator == 0 || ti.rateRefresh.uiDenominator == 0)
|
||||
return false;
|
||||
|
||||
*refresh_rate = static_cast<float>(ti.rateRefresh.uiNumerator) / static_cast<float>(ti.rateRefresh.uiDenominator);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void HostInterface::ToggleSoftwareRendering()
|
||||
{
|
||||
if (System::IsShutdown() || g_settings.gpu_renderer == GPURenderer::Software)
|
||||
|
||||
Reference in New Issue
Block a user