[PATCH 01/11] wined3d: Extract wined3d_swapchain_set_fullscreen() from wined3d_device_reset().
Józef Kucia
jkucia at codeweavers.com
Mon Aug 1 15:28:35 CDT 2016
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/wined3d/device.c | 74 ++++-------------------------------------------
dlls/wined3d/swapchain.c | 71 +++++++++++++++++++++++++++++++++++++++++++++
dlls/wined3d/wined3d.spec | 1 +
include/wine/wined3d.h | 2 ++
4 files changed, 80 insertions(+), 68 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index dfcebc0..c3697d3 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4644,8 +4644,6 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
struct wined3d_rendertarget_view_desc view_desc;
struct wined3d_resource *resource, *cursor;
struct wined3d_swapchain *swapchain;
- struct wined3d_display_mode m;
- BOOL DisplayModeChanged;
HRESULT hr = WINED3D_OK;
unsigned int i;
@@ -4657,7 +4655,6 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
ERR("Failed to get the first implicit swapchain.\n");
return WINED3DERR_INVALIDCALL;
}
- DisplayModeChanged = swapchain->reapply_mode;
if (reset_state)
{
@@ -4736,72 +4733,13 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
wined3d_swapchain_set_window(swapchain, NULL);
}
- if (mode)
- {
- DisplayModeChanged = TRUE;
- m = *mode;
- }
- else if (swapchain_desc->windowed)
- {
- m = swapchain->original_mode;
- }
- else
- {
- m.width = swapchain_desc->backbuffer_width;
- m.height = swapchain_desc->backbuffer_height;
- m.refresh_rate = swapchain_desc->refresh_rate;
- m.format_id = swapchain_desc->backbuffer_format;
- m.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
-
- if ((m.width != swapchain->desc.backbuffer_width
- || m.height != swapchain->desc.backbuffer_height))
- DisplayModeChanged = TRUE;
- }
-
if (!swapchain_desc->windowed != !swapchain->desc.windowed
- || DisplayModeChanged)
+ || swapchain->reapply_mode || mode
+ || swapchain_desc->backbuffer_width != swapchain->desc.backbuffer_width
+ || swapchain_desc->backbuffer_height != swapchain->desc.backbuffer_height)
{
- if (FAILED(hr = wined3d_set_adapter_display_mode(device->wined3d, device->adapter->ordinal, &m)))
- {
- WARN("Failed to set display mode, hr %#x.\n", hr);
- return WINED3DERR_INVALIDCALL;
- }
-
- if (!swapchain_desc->windowed)
- {
- if (swapchain->desc.windowed)
- {
- HWND focus_window = device->create_parms.focus_window;
- if (!focus_window)
- focus_window = swapchain_desc->device_window;
- if (FAILED(hr = wined3d_device_acquire_focus_window(device, focus_window)))
- {
- ERR("Failed to acquire focus window, hr %#x.\n", hr);
- return hr;
- }
-
- /* switch from windowed to fs */
- wined3d_device_setup_fullscreen_window(device, swapchain->device_window,
- swapchain_desc->backbuffer_width,
- swapchain_desc->backbuffer_height);
- }
- else
- {
- /* Fullscreen -> fullscreen mode change */
- MoveWindow(swapchain->device_window, 0, 0,
- swapchain_desc->backbuffer_width,
- swapchain_desc->backbuffer_height,
- TRUE);
- }
- swapchain->d3d_mode = m;
- }
- else if (!swapchain->desc.windowed)
- {
- /* Fullscreen -> windowed switch */
- wined3d_device_restore_fullscreen_window(device, swapchain->device_window);
- wined3d_device_release_focus_window(device);
- }
- swapchain->desc.windowed = swapchain_desc->windowed;
+ if (FAILED(hr = wined3d_swapchain_set_fullscreen(swapchain, swapchain_desc, mode)))
+ return hr;
}
else if (!swapchain_desc->windowed)
{
@@ -4835,7 +4773,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
struct wined3d_resource_desc texture_desc;
struct wined3d_texture *texture;
- TRACE("Creating the depth stencil buffer\n");
+ TRACE("Creating the depth stencil buffer.\n");
texture_desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
texture_desc.format = swapchain->desc.auto_depth_stencil_format;
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 7485c1c..28629ab 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -1387,3 +1387,74 @@ HRESULT CDECL wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapcha
return WINED3D_OK;
}
+
+HRESULT CDECL wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapchain,
+ 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;
+ HRESULT hr;
+
+ TRACE("swapchain %p, desc %p, mode %p.\n", swapchain, swapchain_desc, mode);
+
+ width = swapchain_desc->backbuffer_width;
+ height = swapchain_desc->backbuffer_height;
+
+ if (!mode)
+ {
+ 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;
+ }
+ else
+ {
+ default_mode = swapchain->original_mode;
+ }
+ mode = &default_mode;
+ }
+
+ if (FAILED(hr = wined3d_set_adapter_display_mode(device->wined3d, device->adapter->ordinal, mode)))
+ {
+ WARN("Failed to set display mode, hr %#x.\n", hr);
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (!swapchain_desc->windowed)
+ {
+ if (swapchain->desc.windowed)
+ {
+ HWND focus_window = device->create_parms.focus_window;
+ if (!focus_window)
+ focus_window = swapchain->device_window;
+ if (FAILED(hr = wined3d_device_acquire_focus_window(device, focus_window)))
+ {
+ ERR("Failed to acquire focus window, hr %#x.\n", hr);
+ return hr;
+ }
+
+ /* switch from windowed to fs */
+ wined3d_device_setup_fullscreen_window(device, swapchain->device_window, width, height);
+ }
+ else
+ {
+ /* Fullscreen -> fullscreen mode change */
+ MoveWindow(swapchain->device_window, 0, 0, width, height, TRUE);
+ }
+ swapchain->d3d_mode = *mode;
+ }
+ else if (!swapchain->desc.windowed)
+ {
+ /* Fullscreen -> windowed switch */
+ wined3d_device_restore_fullscreen_window(device, swapchain->device_window);
+ wined3d_device_release_focus_window(device);
+ }
+
+ swapchain->desc.windowed = swapchain_desc->windowed;
+
+ return WINED3D_OK;
+}
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 77b506d..bdf3916 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -242,6 +242,7 @@
@ cdecl wined3d_swapchain_incref(ptr)
@ cdecl wined3d_swapchain_present(ptr ptr ptr ptr long)
@ cdecl wined3d_swapchain_resize_buffers(ptr long long long long long long)
+@ cdecl wined3d_swapchain_set_fullscreen(ptr ptr ptr)
@ cdecl wined3d_swapchain_set_gamma_ramp(ptr long ptr)
@ cdecl wined3d_swapchain_set_palette(ptr ptr)
@ cdecl wined3d_swapchain_set_window(ptr ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index e2f1004..948a57b 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2524,6 +2524,8 @@ HRESULT __cdecl wined3d_swapchain_present(struct wined3d_swapchain *swapchain,
HRESULT __cdecl wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapchain, unsigned int buffer_count,
unsigned int width, unsigned int height, enum wined3d_format_id format_id,
enum wined3d_multisample_type multisample_type, unsigned int multisample_quality);
+HRESULT __cdecl wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapchain,
+ const struct wined3d_swapchain_desc *desc, const struct wined3d_display_mode *mode);
HRESULT __cdecl wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *swapchain,
DWORD flags, const struct wined3d_gamma_ramp *ramp);
void __cdecl wined3d_swapchain_set_palette(struct wined3d_swapchain *swapchain, struct wined3d_palette *palette);
--
2.7.3
More information about the wine-patches
mailing list