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: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2021-01-24 12:14:32 +08:00 committed by Alexandre Julliard
parent 2006f76b5f
commit 8fad0b146d
2 changed files with 25 additions and 2 deletions

View file

@ -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)
{

View file

@ -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);
}