Add pre-tests for the requested mode bpp and frequency. Fields: DM_PELSWIDTH , DM_PELSHEIGHT are re-tested in the testing loop multiple times. These fields must both be set and have already been tested before the loop.
Signed-off-by: Rob Walker bob.mt.wya@gmail.com --- dlls/winex11.drv/settings.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/dlls/winex11.drv/settings.c b/dlls/winex11.drv/settings.c index afa26cf543..b0164d5806 100644 --- a/dlls/winex11.drv/settings.c +++ b/dlls/winex11.drv/settings.c @@ -344,7 +344,7 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode, { DWORD i, dwBpp = 0; DEVMODEW dm; - BOOL def_mode = TRUE; + BOOL def_mode = TRUE, test_bpp, test_frequency;
TRACE("(%s,%p,%p,0x%08x,%p)\n",debugstr_w(devname),devmode,hwnd,flags,lpvoid); TRACE("flags=%s\n",_CDS_flags(flags)); @@ -387,29 +387,24 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode, return DISP_CHANGE_BADMODE; }
+ test_bpp = devmode->dmFields & DM_BITSPERPEL; + test_frequency = (devmode->dmFields & DM_DISPLAYFREQUENCY) && + (devmode->dmDisplayFrequency != 0); for (i = 0; i < dd_mode_count; i++) { - if (devmode->dmFields & DM_BITSPERPEL) + if (devmode->dmPelsWidth != dd_modes[i].width) continue; + if (devmode->dmPelsHeight != dd_modes[i].height) continue; + if (test_bpp) { if (dwBpp != dd_modes[i].bpp) continue; } - if (devmode->dmFields & DM_PELSWIDTH) - { - if (devmode->dmPelsWidth != dd_modes[i].width) - continue; - } - if (devmode->dmFields & DM_PELSHEIGHT) - { - if (devmode->dmPelsHeight != dd_modes[i].height) - continue; - } - if ((devmode->dmFields & DM_DISPLAYFREQUENCY) && (dd_modes[i].refresh_rate != 0) && - devmode->dmDisplayFrequency != 0) + if (test_frequency && (dd_modes[i].refresh_rate != 0)) { if (devmode->dmDisplayFrequency != dd_modes[i].refresh_rate) continue; } + /* we have a valid mode */ TRACE("Requested display settings match mode %d (%s)\n", i, handler_name);
The failed mode error message dumps all the mode fields, that were being tested. Change this output so that only the mode fields explicitly being matched against are displayed. Make the failed message use formatting consist with the trace message, used earlier in this function.
Signed-off-by: Rob Walker bob.mt.wya@gmail.com --- dlls/winex11.drv/settings.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/dlls/winex11.drv/settings.c b/dlls/winex11.drv/settings.c index b0164d5806..733a7130f1 100644 --- a/dlls/winex11.drv/settings.c +++ b/dlls/winex11.drv/settings.c @@ -345,6 +345,7 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode, DWORD i, dwBpp = 0; DEVMODEW dm; BOOL def_mode = TRUE, test_bpp, test_frequency; + char bbp_buffer[16] = "", freq_buffer[16] = "";
TRACE("(%s,%p,%p,0x%08x,%p)\n",debugstr_w(devname),devmode,hwnd,flags,lpvoid); TRACE("flags=%s\n",_CDS_flags(flags)); @@ -417,9 +418,13 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode, return DISP_CHANGE_SUCCESSFUL; }
- /* no valid modes found */ - ERR("No matching mode found %ux%ux%u @%u! (%s)\n", - devmode->dmPelsWidth, devmode->dmPelsHeight, - devmode->dmBitsPerPel, devmode->dmDisplayFrequency, handler_name); + /* no valid modes found, only print the fields we were trying to matching against */ + if (test_bpp) + snprintf(bbp_buffer, ARRAY_SIZE(bbp_buffer), "bbp=%d ", devmode->dmBitsPerPel); + if (test_frequency) + snprintf(freq_buffer, ARRAY_SIZE(freq_buffer), "freq=%d ", devmode->dmDisplayFrequency); + ERR("No matching mode found: width=%d height=%d %s%s(%s)\n", + devmode->dmPelsWidth, devmode->dmPelsHeight, bbp_buffer, freq_buffer, handler_name); + return DISP_CHANGE_BADMODE; }
On 08/06/2018 02:56 PM, Rob Walker wrote:
Add pre-tests for the requested mode bpp and frequency.
Is this really an optimization worth performing?