Commit 5e4145d0 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Skip redundant mode setting calls.

parent 87b45c35
......@@ -830,6 +830,7 @@ static HRESULT WINAPI ddraw1_SetCooperativeLevel(IDirectDraw *iface, HWND window
static HRESULT ddraw_set_display_mode(IDirectDrawImpl *ddraw, DWORD Width, DWORD Height,
DWORD BPP, DWORD RefreshRate, DWORD Flags)
{
enum wined3d_format_id format;
WINED3DDISPLAYMODE Mode;
HRESULT hr;
......@@ -845,6 +846,30 @@ static HRESULT ddraw_set_display_mode(IDirectDrawImpl *ddraw, DWORD Width, DWORD
return DD_OK;
}
switch(BPP)
{
case 8: format = WINED3DFMT_P8_UINT; break;
case 15: format = WINED3DFMT_B5G5R5X1_UNORM; break;
case 16: format = WINED3DFMT_B5G6R5_UNORM; break;
case 24: format = WINED3DFMT_B8G8R8_UNORM; break;
case 32: format = WINED3DFMT_B8G8R8X8_UNORM; break;
default: format = WINED3DFMT_UNKNOWN; break;
}
if (FAILED(hr = IWineD3DDevice_GetDisplayMode(ddraw->wineD3DDevice, 0, &Mode)))
{
ERR("Failed to get current display mode, hr %#x.\n", hr);
}
else if (Mode.Width == Width
&& Mode.Height == Height
&& Mode.Format == format
&& Mode.RefreshRate == RefreshRate)
{
TRACE("Skipping redundant mode setting call.\n");
LeaveCriticalSection(&ddraw_cs);
return DD_OK;
}
/* Check the exclusive mode
if(!(ddraw->cooperative_level & DDSCL_EXCLUSIVE))
return DDERR_NOEXCLUSIVEMODE;
......@@ -857,14 +882,7 @@ static HRESULT ddraw_set_display_mode(IDirectDrawImpl *ddraw, DWORD Width, DWORD
Mode.Width = Width;
Mode.Height = Height;
Mode.RefreshRate = RefreshRate;
switch(BPP)
{
case 8: Mode.Format = WINED3DFMT_P8_UINT; break;
case 15: Mode.Format = WINED3DFMT_B5G5R5X1_UNORM; break;
case 16: Mode.Format = WINED3DFMT_B5G6R5_UNORM; break;
case 24: Mode.Format = WINED3DFMT_B8G8R8_UNORM; break;
case 32: Mode.Format = WINED3DFMT_B8G8R8X8_UNORM; break;
}
Mode.Format = format;
/* TODO: The possible return values from msdn suggest that
* the screen mode can't be changed if a surface is locked
......
......@@ -3974,7 +3974,7 @@ static void test_redundant_mode_set(void)
ok(SUCCEEDED(hr), "SetDipslayMode failed, hr %#x.\n", hr);
GetWindowRect(window, &s);
todo_wine ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
r.left, r.top, r.right, r.bottom,
s.left, s.top, s.right, s.bottom);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment