=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: wined3d: Optionally use closest matching mode in wined3d_swapchain_set_fullscreen( ).

Alexandre Julliard julliard at winehq.org
Fri Aug 26 10:18:11 CDT 2016


Module: wine
Branch: master
Commit: 92a6c5839d9ebda9b94facbfd5bdac1bbb423600
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=92a6c5839d9ebda9b94facbfd5bdac1bbb423600

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Thu Aug 25 12:22:54 2016 +0200

wined3d: Optionally use closest matching mode in wined3d_swapchain_set_fullscreen().

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/swapchain.c | 48 ++++++++++++++++++++++++++++--------------------
 include/wine/wined3d.h   |  3 ++-
 2 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index e405457..fdfe337 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -1450,35 +1450,44 @@ HRESULT CDECL wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapcha
         const struct wined3d_swapchain_desc *swapchain_desc, const struct wined3d_display_mode *mode)
 {
     struct wined3d_device *device = swapchain->device;
-    struct wined3d_display_mode default_mode;
-    unsigned int width, height;
+    struct wined3d_display_mode actual_mode;
     HRESULT hr;
 
     TRACE("swapchain %p, desc %p, mode %p.\n", swapchain, swapchain_desc, mode);
 
     if (swapchain->desc.flags & WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH)
     {
-        width = swapchain_desc->backbuffer_width;
-        height = swapchain_desc->backbuffer_height;
-
-        if (!mode)
+        if (mode)
+        {
+            actual_mode = *mode;
+        }
+        else
         {
             if (!swapchain_desc->windowed)
             {
-                default_mode.width = swapchain_desc->backbuffer_width;
-                default_mode.height = swapchain_desc->backbuffer_height;
-                default_mode.refresh_rate = swapchain_desc->refresh_rate;
-                default_mode.format_id = swapchain_desc->backbuffer_format;
-                default_mode.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
+                actual_mode.width = swapchain_desc->backbuffer_width;
+                actual_mode.height = swapchain_desc->backbuffer_height;
+                actual_mode.refresh_rate = swapchain_desc->refresh_rate;
+                actual_mode.format_id = swapchain_desc->backbuffer_format;
+                actual_mode.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
             }
             else
             {
-                default_mode = swapchain->original_mode;
+                actual_mode = swapchain->original_mode;
             }
-            mode = &default_mode;
         }
 
-        if (FAILED(hr = wined3d_set_adapter_display_mode(device->wined3d, device->adapter->ordinal, mode)))
+        if (swapchain->desc.flags & WINED3D_SWAPCHAIN_USE_CLOSEST_MATCHING_MODE)
+        {
+            if (FAILED(hr = wined3d_find_closest_matching_adapter_mode(device->wined3d,
+                    device->adapter->ordinal, &actual_mode)))
+            {
+                WARN("Failed to find closest matching mode, hr %#x.\n", hr);
+            }
+        }
+
+        if (FAILED(hr = wined3d_set_adapter_display_mode(device->wined3d,
+                device->adapter->ordinal, &actual_mode)))
         {
             WARN("Failed to set display mode, hr %#x.\n", hr);
             return WINED3DERR_INVALIDCALL;
@@ -1490,19 +1499,18 @@ HRESULT CDECL wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapcha
             WARN("WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH is not set, ignoring mode.\n");
 
         if (FAILED(hr = wined3d_get_adapter_display_mode(device->wined3d, device->adapter->ordinal,
-                &default_mode, NULL)))
+                &actual_mode, NULL)))
         {
             ERR("Failed to get display mode, hr %#x.\n", hr);
             return WINED3DERR_INVALIDCALL;
         }
-        mode = &default_mode;
-
-        width = mode->width;
-        height = mode->height;
     }
 
     if (!swapchain_desc->windowed)
     {
+        unsigned int width = actual_mode.width;
+        unsigned int height = actual_mode.height;
+
         if (swapchain->desc.windowed)
         {
             HWND focus_window = device->create_parms.focus_window;
@@ -1522,7 +1530,7 @@ HRESULT CDECL wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapcha
             /* Fullscreen -> fullscreen mode change */
             MoveWindow(swapchain->device_window, 0, 0, width, height, TRUE);
         }
-        swapchain->d3d_mode = *mode;
+        swapchain->d3d_mode = actual_mode;
     }
     else if (!swapchain->desc.windowed)
     {
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index bc343ec..81dffea 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -829,7 +829,8 @@ enum wined3d_display_rotation
 #define WINED3D_SWAPCHAIN_NOAUTOROTATE                          0x00000020u
 #define WINED3D_SWAPCHAIN_UNPRUNEDMODE                          0x00000040u
 #define WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH                     0x00001000u
-#define WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT                   0x00002000u
+#define WINED3D_SWAPCHAIN_USE_CLOSEST_MATCHING_MODE             0x00002000u
+#define WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT                   0x00004000u
 
 #define WINED3DDP_MAXTEXCOORD                                   8
 




More information about the wine-cvs mailing list