Module: wine Branch: master Commit: 4bc4e431c852ce3589b6f8c262b92e5f6ab22348 URL: http://source.winehq.org/git/wine.git/?a=commit;h=4bc4e431c852ce3589b6f8c262...
Author: Józef Kucia jkucia@codeweavers.com Date: Thu Aug 25 12:34:19 2016 +0200
d3d8/tests: Prefer higher resolutions in test_reset().
Signed-off-by: Józef Kucia jkucia@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/d3d8/tests/device.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 2f9c267..530ef00 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -22,6 +22,7 @@ */
#define WINVER 0x0602 /* for CURSOR_SUPPRESSED */ +#include <stdlib.h> #define COBJMACROS #include <initguid.h> #include <d3d8.h> @@ -1269,6 +1270,21 @@ static void test_display_modes(void) IDirect3D8_Release(d3d); }
+struct mode +{ + unsigned int w; + unsigned int h; +}; + +static int compare_mode(const void *a, const void *b) +{ + const struct mode *mode_a = a; + const struct mode *mode_b = b; + unsigned int w = mode_a->w - mode_b->w; + unsigned int h = mode_b->h - mode_b->h; + return abs(w) >= abs(h) ? -w : -h; +} + static void test_reset(void) { UINT width, orig_width = GetSystemMetrics(SM_CXSCREEN); @@ -1303,11 +1319,7 @@ static void test_reset(void) D3DVSD_END(), };
- struct - { - UINT w; - UINT h; - } *modes = NULL; + struct mode *modes = NULL;
window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL); @@ -1358,6 +1370,9 @@ static void test_reset(void) goto cleanup; }
+ /* Prefer higher resolutions. */ + qsort(modes, mode_count, sizeof(*modes), compare_mode); + i = 0; if (modes[i].w == orig_width && modes[i].h == orig_height) ++i;