wined3d: Extract wined3d_swapchain_set_fullscreen() from wined3d_device_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>
This commit is contained in:
parent
a4fabd283d
commit
cad279449c
|
@ -4641,8 +4641,6 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
|
||||||
struct wined3d_rendertarget_view_desc view_desc;
|
struct wined3d_rendertarget_view_desc view_desc;
|
||||||
struct wined3d_resource *resource, *cursor;
|
struct wined3d_resource *resource, *cursor;
|
||||||
struct wined3d_swapchain *swapchain;
|
struct wined3d_swapchain *swapchain;
|
||||||
struct wined3d_display_mode m;
|
|
||||||
BOOL DisplayModeChanged;
|
|
||||||
HRESULT hr = WINED3D_OK;
|
HRESULT hr = WINED3D_OK;
|
||||||
unsigned int i;
|
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");
|
ERR("Failed to get the first implicit swapchain.\n");
|
||||||
return WINED3DERR_INVALIDCALL;
|
return WINED3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
DisplayModeChanged = swapchain->reapply_mode;
|
|
||||||
|
|
||||||
if (reset_state)
|
if (reset_state)
|
||||||
{
|
{
|
||||||
|
@ -4733,72 +4730,13 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
|
||||||
wined3d_swapchain_set_window(swapchain, NULL);
|
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
|
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)))
|
if (FAILED(hr = wined3d_swapchain_set_fullscreen(swapchain, swapchain_desc, mode)))
|
||||||
{
|
return hr;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
else if (!swapchain_desc->windowed)
|
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_resource_desc texture_desc;
|
||||||
struct wined3d_texture *texture;
|
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.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||||
texture_desc.format = swapchain->desc.auto_depth_stencil_format;
|
texture_desc.format = swapchain->desc.auto_depth_stencil_format;
|
||||||
|
|
|
@ -1387,3 +1387,74 @@ HRESULT CDECL wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapcha
|
||||||
|
|
||||||
return WINED3D_OK;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -242,6 +242,7 @@
|
||||||
@ cdecl wined3d_swapchain_incref(ptr)
|
@ cdecl wined3d_swapchain_incref(ptr)
|
||||||
@ cdecl wined3d_swapchain_present(ptr ptr ptr ptr long)
|
@ cdecl wined3d_swapchain_present(ptr ptr ptr ptr long)
|
||||||
@ cdecl wined3d_swapchain_resize_buffers(ptr long long long long long 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_gamma_ramp(ptr long ptr)
|
||||||
@ cdecl wined3d_swapchain_set_palette(ptr ptr)
|
@ cdecl wined3d_swapchain_set_palette(ptr ptr)
|
||||||
@ cdecl wined3d_swapchain_set_window(ptr ptr)
|
@ cdecl wined3d_swapchain_set_window(ptr ptr)
|
||||||
|
|
|
@ -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,
|
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,
|
unsigned int width, unsigned int height, enum wined3d_format_id format_id,
|
||||||
enum wined3d_multisample_type multisample_type, unsigned int multisample_quality);
|
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,
|
HRESULT __cdecl wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *swapchain,
|
||||||
DWORD flags, const struct wined3d_gamma_ramp *ramp);
|
DWORD flags, const struct wined3d_gamma_ramp *ramp);
|
||||||
void __cdecl wined3d_swapchain_set_palette(struct wined3d_swapchain *swapchain, struct wined3d_palette *palette);
|
void __cdecl wined3d_swapchain_set_palette(struct wined3d_swapchain *swapchain, struct wined3d_palette *palette);
|
||||||
|
|
Loading…
Reference in New Issue