|
|
|
@ -5,6 +5,7 @@
|
|
|
|
#include "common/log.h"
|
|
|
|
#include "common/log.h"
|
|
|
|
#include "common/string_util.h"
|
|
|
|
#include "common/string_util.h"
|
|
|
|
#include "common/timer.h"
|
|
|
|
#include "common/timer.h"
|
|
|
|
|
|
|
|
#include "host_interface.h"
|
|
|
|
#include "stb_image.h"
|
|
|
|
#include "stb_image.h"
|
|
|
|
#include "stb_image_resize.h"
|
|
|
|
#include "stb_image_resize.h"
|
|
|
|
#include "stb_image_write.h"
|
|
|
|
#include "stb_image_write.h"
|
|
|
|
@ -15,11 +16,6 @@
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
Log_SetChannel(HostDisplay);
|
|
|
|
Log_SetChannel(HostDisplay);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
#include "common/windows_headers.h"
|
|
|
|
|
|
|
|
#include <dwmapi.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HostDisplayTexture::~HostDisplayTexture() = default;
|
|
|
|
HostDisplayTexture::~HostDisplayTexture() = default;
|
|
|
|
|
|
|
|
|
|
|
|
HostDisplay::~HostDisplay() = default;
|
|
|
|
HostDisplay::~HostDisplay() = default;
|
|
|
|
@ -92,39 +88,7 @@ bool HostDisplay::SetDisplayPixels(HostDisplayPixelFormat format, u32 width, u32
|
|
|
|
|
|
|
|
|
|
|
|
bool HostDisplay::GetHostRefreshRate(float* refresh_rate)
|
|
|
|
bool HostDisplay::GetHostRefreshRate(float* refresh_rate)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
return g_host_interface->GetMainDisplayRefreshRate(refresh_rate);
|
|
|
|
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 HostDisplay::SetSoftwareCursor(std::unique_ptr<HostDisplayTexture> texture, float scale /*= 1.0f*/)
|
|
|
|
void HostDisplay::SetSoftwareCursor(std::unique_ptr<HostDisplayTexture> texture, float scale /*= 1.0f*/)
|
|
|
|
|