wined3d: Store the original display mode in the swapchain.

This commit is contained in:
Henri Verbeet 2013-08-20 10:20:09 +02:00 committed by Alexandre Julliard
parent d04d1c1736
commit 7e7bd87b2c
3 changed files with 14 additions and 34 deletions

View File

@ -5012,11 +5012,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
}
else if (swapchain_desc->windowed)
{
m.width = swapchain->orig_width;
m.height = swapchain->orig_height;
m.refresh_rate = 0;
m.format_id = swapchain->desc.backbuffer_format;
m.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
m = swapchain->original_mode;
}
else
{

View File

@ -30,7 +30,6 @@ WINE_DECLARE_DEBUG_CHANNEL(fps);
/* Do not call while under the GL lock. */
static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
{
struct wined3d_display_mode mode;
HRESULT hr;
UINT i;
@ -76,13 +75,8 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
* orig_height will be equal to the modes in the presentation params. */
if (!swapchain->desc.windowed && swapchain->desc.auto_restore_display_mode)
{
mode.width = swapchain->orig_width;
mode.height = swapchain->orig_height;
mode.refresh_rate = 0;
mode.format_id = swapchain->orig_fmt;
mode.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
if (FAILED(hr = wined3d_set_adapter_display_mode(swapchain->device->wined3d,
swapchain->device->adapter->ordinal, &mode)))
swapchain->device->adapter->ordinal, &swapchain->original_mode)))
ERR("Failed to restore display mode, hr %#x.\n", hr);
}
@ -818,8 +812,6 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
{
const struct wined3d_adapter *adapter = device->adapter;
struct wined3d_resource_desc surface_desc;
const struct wined3d_format *format;
struct wined3d_display_mode mode;
BOOL displaymode_set = FALSE;
RECT client_rect;
HWND window;
@ -853,11 +845,12 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
swapchain->win_handle = window;
swapchain->device_window = window;
wined3d_get_adapter_display_mode(device->wined3d, adapter->ordinal, &mode, NULL);
swapchain->orig_width = mode.width;
swapchain->orig_height = mode.height;
swapchain->orig_fmt = mode.format_id;
format = wined3d_get_format(&adapter->gl_info, mode.format_id);
if (FAILED(hr = wined3d_get_adapter_display_mode(device->wined3d,
adapter->ordinal, &swapchain->original_mode, NULL)))
{
ERR("Failed to get current display mode, hr %#x.\n", hr);
goto err;
}
GetClientRect(window, &client_rect);
if (desc->windowed
@ -879,8 +872,8 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
if (desc->backbuffer_format == WINED3DFMT_UNKNOWN)
{
desc->backbuffer_format = swapchain->orig_fmt;
TRACE("Updating format to %s.\n", debug_d3dformat(swapchain->orig_fmt));
desc->backbuffer_format = swapchain->original_mode.format_id;
TRACE("Updating format to %s.\n", debug_d3dformat(swapchain->original_mode.format_id));
}
}
swapchain->desc = *desc;
@ -1040,18 +1033,10 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
err:
if (displaymode_set)
{
DEVMODEW devmode;
if (FAILED(wined3d_set_adapter_display_mode(device->wined3d,
adapter->ordinal, &swapchain->original_mode)))
ERR("Failed to restore display mode.\n");
ClipCursor(NULL);
/* Change the display settings */
memset(&devmode, 0, sizeof(devmode));
devmode.dmSize = sizeof(devmode);
devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
devmode.dmBitsPerPel = format->byte_count * CHAR_BIT;
devmode.dmPelsWidth = swapchain->orig_width;
devmode.dmPelsHeight = swapchain->orig_height;
ChangeDisplaySettingsExW(adapter->DeviceName, &devmode, NULL, CDS_FULLSCREEN, NULL);
}
if (swapchain->back_buffers)

View File

@ -2543,8 +2543,7 @@ struct wined3d_swapchain
struct wined3d_surface **back_buffers;
struct wined3d_surface *front_buffer;
struct wined3d_swapchain_desc desc;
DWORD orig_width, orig_height;
enum wined3d_format_id orig_fmt;
struct wined3d_display_mode original_mode;
struct wined3d_gamma_ramp orig_gamma;
BOOL render_to_fbo;
const struct wined3d_format *ds_format;