From cad279449c62a965a70a712a91b11ba52c4ff4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Mon, 1 Aug 2016 22:28:35 +0200 Subject: [PATCH] wined3d: Extract wined3d_swapchain_set_fullscreen() from wined3d_device_reset(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- 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 bb3a23b7267..55046db10f2 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4641,8 +4641,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; @@ -4654,7 +4652,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) { @@ -4733,72 +4730,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) { @@ -4832,7 +4770,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 7485c1ce4b8..28629abe1f9 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 77b506d8da2..bdf39160930 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 e2f1004be60..948a57baae1 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);