Commit 8fad0b14 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

gdi32: Report real VREFRESH values for GetDeviceCaps() with display DCs.

Even though MSDN says 0 and 1 are both valid and they represent the default refresh rate of display hardware. Some games rely on the value being the real refresh rate and use it to cap frame rates. Fix an issue that Sakuna: Of Rice and Ruin reports monitors of 1Hz and cap to 1fps. Signed-off-by: 's avatarZhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 2006f76b
......@@ -82,6 +82,7 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
static BOOL (WINAPI *pEnumDisplayMonitors)(HDC, LPRECT, MONITORENUMPROC, LPARAM);
static BOOL (WINAPI *pEnumDisplaySettingsW)(LPCWSTR, DWORD, LPDEVMODEW);
static HWND (WINAPI *pGetDesktopWindow)(void);
static BOOL (WINAPI *pGetMonitorInfoW)(HMONITOR, LPMONITORINFO);
static INT (WINAPI *pGetSystemMetrics)(INT);
......@@ -245,6 +246,7 @@ void CDECL __wine_set_display_driver( HMODULE module )
pGetMonitorInfoW = (void *)GetProcAddress( user32, "GetMonitorInfoW" );
pGetSystemMetrics = (void *)GetProcAddress( user32, "GetSystemMetrics" );
pEnumDisplayMonitors = (void *)GetProcAddress( user32, "EnumDisplayMonitors" );
pEnumDisplaySettingsW = (void *)GetProcAddress( user32, "EnumDisplaySettingsW" );
pSetThreadDpiAwarenessContext = (void *)GetProcAddress( user32, "SetThreadDpiAwarenessContext" );
}
......@@ -471,7 +473,28 @@ static INT CDECL nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
case PHYSICALOFFSETY: return 0;
case SCALINGFACTORX: return 0;
case SCALINGFACTORY: return 0;
case VREFRESH: return GetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY ? 1 : 0;
case VREFRESH:
{
DEVMODEW devmode;
WCHAR *display;
DC *dc;
if (GetDeviceCaps( dev->hdc, TECHNOLOGY ) != DT_RASDISPLAY)
return 0;
if (pEnumDisplaySettingsW)
{
dc = get_nulldrv_dc( dev );
memset( &devmode, 0, sizeof(devmode) );
devmode.dmSize = sizeof(devmode);
display = dc->display[0] ? dc->display : NULL;
if (pEnumDisplaySettingsW( display, ENUM_CURRENT_SETTINGS, &devmode ))
return devmode.dmDisplayFrequency ? devmode.dmDisplayFrequency : 1;
}
return 1;
}
case DESKTOPHORZRES:
if (GetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY && pGetSystemMetrics)
{
......
......@@ -2020,7 +2020,7 @@ static void _check_display_dc(INT line, HDC hdc, const DEVMODEA *dm, BOOL allow_
dm->dmPelsHeight, value);
value = GetDeviceCaps(hdc, VREFRESH);
todo_wine_if(value != dm->dmDisplayFrequency && value == 1)
todo_wine_if(allow_todo)
ok_(__FILE__, line)(value == dm->dmDisplayFrequency, "Expected VREFRESH %d, got %d.\n",
dm->dmDisplayFrequency, value);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment