mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 16:20:27 +00:00
(Win32/DispServer) Improve video resolution switching
* Only switch to a display mode with the same current bit-depth and screen rotation * Only switch to a display mode with default stretching mode * Cleanup the function for consistency with other functions
This commit is contained in:
parent
9ec3a5ccad
commit
2e57a690ce
@ -222,64 +222,70 @@ static bool win32_display_server_set_window_decorations(void *data, bool on)
|
||||
static bool win32_display_server_set_resolution(void *data,
|
||||
unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset)
|
||||
{
|
||||
DEVMODE curDevmode;
|
||||
int iModeNum;
|
||||
int freq = int_hz;
|
||||
int depth = 0;
|
||||
dispserv_win32_t *serv = (dispserv_win32_t*)data;
|
||||
DEVMODE dm = {0};
|
||||
LONG res = 0;
|
||||
unsigned i = 0;
|
||||
unsigned curr_bpp = 0;
|
||||
#if _WIN32_WINNT >= 0x0500
|
||||
unsigned curr_orientation = 0;
|
||||
#endif
|
||||
dispserv_win32_t *serv = (dispserv_win32_t*)data;
|
||||
|
||||
if (!serv)
|
||||
return false;
|
||||
|
||||
win32_get_video_output(&curDevmode, -1, sizeof(curDevmode));
|
||||
win32_get_video_output(&dm, -1, sizeof(dm));
|
||||
|
||||
if (serv->orig_width == 0)
|
||||
serv->orig_width = GetSystemMetrics(SM_CXSCREEN);
|
||||
serv->orig_refresh = curDevmode.dmDisplayFrequency;
|
||||
serv->orig_width = GetSystemMetrics(SM_CXSCREEN);
|
||||
if (serv->orig_height == 0)
|
||||
serv->orig_height = GetSystemMetrics(SM_CYSCREEN);
|
||||
serv->orig_height = GetSystemMetrics(SM_CYSCREEN);
|
||||
serv->orig_refresh = dm.dmDisplayFrequency;
|
||||
|
||||
/* Used to stop super resolution bug */
|
||||
if (width == curDevmode.dmPelsWidth)
|
||||
width = 0;
|
||||
if (width == dm.dmPelsWidth)
|
||||
width = 0;
|
||||
if (width == 0)
|
||||
width = curDevmode.dmPelsWidth;
|
||||
width = dm.dmPelsWidth;
|
||||
if (height == 0)
|
||||
height = curDevmode.dmPelsHeight;
|
||||
if (depth == 0)
|
||||
depth = curDevmode.dmBitsPerPel;
|
||||
if (freq == 0)
|
||||
freq = curDevmode.dmDisplayFrequency;
|
||||
height = dm.dmPelsHeight;
|
||||
if (curr_bpp == 0)
|
||||
curr_bpp = dm.dmBitsPerPel;
|
||||
if (int_hz == 0)
|
||||
int_hz = dm.dmDisplayFrequency;
|
||||
#if _WIN32_WINNT >= 0x0500
|
||||
if (curr_orientation == 0)
|
||||
curr_orientation = dm.dmDisplayOrientation;
|
||||
#endif
|
||||
|
||||
for (iModeNum = 0;; iModeNum++)
|
||||
for (i = 0; win32_get_video_output(&dm, i, sizeof(dm)); i++)
|
||||
{
|
||||
LONG res;
|
||||
DEVMODE devmode;
|
||||
|
||||
if (!win32_get_video_output(&devmode, iModeNum, sizeof(devmode)))
|
||||
break;
|
||||
|
||||
if (devmode.dmPelsWidth != width)
|
||||
if (dm.dmPelsWidth != width)
|
||||
continue;
|
||||
|
||||
if (devmode.dmPelsHeight != height)
|
||||
if (dm.dmPelsHeight != height)
|
||||
continue;
|
||||
|
||||
if (devmode.dmBitsPerPel != depth)
|
||||
if (dm.dmBitsPerPel != curr_bpp)
|
||||
continue;
|
||||
|
||||
if (devmode.dmDisplayFrequency != freq)
|
||||
if (dm.dmDisplayFrequency != int_hz)
|
||||
continue;
|
||||
#if _WIN32_WINNT >= 0x0500
|
||||
if (dm.dmDisplayOrientation != curr_orientation)
|
||||
continue;
|
||||
if (dm.dmDisplayFixedOutput != DMDFO_DEFAULT)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
devmode.dmFields |=
|
||||
DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
|
||||
res =
|
||||
win32_change_display_settings(NULL, &devmode, CDS_TEST);
|
||||
dm.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
|
||||
#if _WIN32_WINNT >= 0x0500
|
||||
dm.dmFields |= DM_DISPLAYORIENTATION;
|
||||
#endif
|
||||
|
||||
res = win32_change_display_settings(NULL, &dm, CDS_TEST);
|
||||
|
||||
switch (res)
|
||||
{
|
||||
case DISP_CHANGE_SUCCESSFUL:
|
||||
res = win32_change_display_settings(NULL, &devmode, 0);
|
||||
res = win32_change_display_settings(NULL, &dm, 0);
|
||||
switch (res)
|
||||
{
|
||||
case DISP_CHANGE_SUCCESSFUL:
|
||||
|
Loading…
x
Reference in New Issue
Block a user