[PATCH v2] d3d8/tests: Prefer higher resolutions in test_reset().

Józef Kucia jkucia at codeweavers.com
Thu Aug 25 05:34:19 CDT 2016


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---

Version 2: Define WINVER before including stdlib.h

---
 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;
 
-- 
2.7.3




More information about the wine-patches mailing list