From fafe6df976876e2c876359fcd5a93d50acf97606 Mon Sep 17 00:00:00 2001 From: Louis Lenders Date: Tue, 20 Jul 2010 23:03:37 +0200 Subject: d3d9: Partially implement GetAdapterDisplayModeEx --- dlls/d3d9/directx.c | 32 +++++++++++++++++++++++++++++--- dlls/d3d9/tests/d3d9ex.c | 16 ++++++++-------- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c index 2ad2767..ff5101d 100644 --- a/dlls/d3d9/directx.c +++ b/dlls/d3d9/directx.c @@ -460,10 +460,36 @@ static HRESULT WINAPI IDirect3D9ExImpl_EnumAdapterModesEx(IDirect3D9Ex *iface, static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterDisplayModeEx(IDirect3D9Ex *iface, UINT adapter, D3DDISPLAYMODEEX *mode, D3DDISPLAYROTATION *rotation) { - FIXME("iface %p, adapter %u, mode %p, rotation %p stub!\n", - iface, adapter, mode, rotation); + HRESULT hr; + WINED3DDISPLAYMODE m; + struct wined3d_adapter_info_ex *adapterinfo; + IDirect3D9Impl *This = (IDirect3D9Impl *)iface; + + TRACE("iface %p, adapter %u, mode %p.\n", iface, adapter, mode); + TRACE("iface %p, adapter %u, mode %p, rotation %p\n", iface, adapter, mode, rotation); - return D3DERR_DRIVERINTERNALERROR; + if(mode->Size != sizeof(D3DDISPLAYMODEEX)) + return D3DERR_INVALIDCALL; + + adapterinfo = HeapAlloc(GetProcessHeap(), 0, sizeof(*adapterinfo)); + + wined3d_mutex_lock(); + hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, adapter, &m, adapterinfo); + wined3d_mutex_unlock(); + + if (SUCCEEDED(hr)) + { + mode->Width = m.Width; + mode->Height = m.Height; + mode->RefreshRate = m.RefreshRate; + mode->Format = d3dformat_from_wined3dformat(m.Format); + mode->ScanLineOrdering = adapterinfo->ScanLineOrdering; + + if (rotation) + *rotation = adapterinfo->Rotation; + } + + return hr; } static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9ExImpl_CreateDeviceEx(IDirect3D9Ex *iface, diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c index 5af2e4e..75eb30d 100644 --- a/dlls/d3d9/tests/d3d9ex.c +++ b/dlls/d3d9/tests/d3d9ex.c @@ -288,27 +288,27 @@ static void test_get_adapter_displaymode_ex(void) /*now that orientation has changed start tests for GetAdapterDisplayModeEx: invalid Size*/ memset(&mode_ex, 0, sizeof(mode_ex)); hr = IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9ex, D3DADAPTER_DEFAULT, &mode_ex, &rotation); - todo_wine ok(hr == D3DERR_INVALIDCALL, "GetAdapterDisplayModeEx returned %#x instead of D3DERR_INVALIDCALL\n", hr); + ok(hr == D3DERR_INVALIDCALL, "GetAdapterDisplayModeEx returned %#x instead of D3DERR_INVALIDCALL\n", hr); mode_ex.Size = sizeof(D3DDISPLAYMODEEX); /* invalid count*/ hr = IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9ex, count + 1, &mode_ex, &rotation); - todo_wine ok(hr == D3DERR_INVALIDCALL, "GetAdapterDisplayModeEx returned %#x instead of D3DERR_INVALIDCALL\n", hr); + ok(hr == D3DERR_INVALIDCALL, "GetAdapterDisplayModeEx returned %#x instead of D3DERR_INVALIDCALL\n", hr); /*valid count and valid Size*/ hr = IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9ex, D3DADAPTER_DEFAULT, &mode_ex, &rotation); - todo_wine ok(SUCCEEDED(hr), "GetAdapterDisplayModeEx failed, hr %#x.\n", hr); + ok(SUCCEEDED(hr), "GetAdapterDisplayModeEx failed, hr %#x.\n", hr); /* Compare what GetAdapterDisplayMode returns with what GetAdapterDisplayModeEx returns*/ hr = IDirect3D9_GetAdapterDisplayMode(d3d9, D3DADAPTER_DEFAULT, &mode); ok(SUCCEEDED(hr), "GetAdapterDisplayMode failed, hr %#x.\n", hr); ok(mode_ex.Size == sizeof(D3DDISPLAYMODEEX), "size is %d instead of %d\n", mode_ex.Size, sizeof(D3DDISPLAYMODEEX)); - todo_wine ok(mode_ex.Width == mode.Width, "width is %d instead of %d\n", mode_ex.Width, mode.Width); - todo_wine ok(mode_ex.Height == mode.Height, "height is %d instead of %d\n", mode_ex.Height, mode.Height); - todo_wine ok(mode_ex.RefreshRate == mode.RefreshRate, "RefreshRate is %d instead of %d\n", mode_ex.RefreshRate, mode.RefreshRate); - todo_wine ok(mode_ex.Format == mode.Format, "format is %x instead of %x\n", mode_ex.Format, mode.Format); + ok(mode_ex.Width == mode.Width, "width is %d instead of %d\n", mode_ex.Width, mode.Width); + ok(mode_ex.Height == mode.Height, "height is %d instead of %d\n", mode_ex.Height, mode.Height); + ok(mode_ex.RefreshRate == mode.RefreshRate, "RefreshRate is %d instead of %d\n", mode_ex.RefreshRate, mode.RefreshRate); + ok(mode_ex.Format == mode.Format, "format is %x instead of %x\n", mode_ex.Format, mode.Format); /* don't know yet how to test for ScanLineOrdering, just testing that it is set to a value by GetAdapterDisplayModeEx*/ - todo_wine ok(mode_ex.ScanLineOrdering != 0, "ScanLineOrdering returned 0\n"); + ok(mode_ex.ScanLineOrdering != 0, "ScanLineOrdering returned 0\n"); /* check that orientation is returned correctly by GetAdapterDisplayModeEx and EnumDisplaySettingsEx*/ todo_wine ok(startmode.dmDisplayOrientation == DMDO_180 && rotation == D3DDISPLAYROTATION_180, "rotation is %d instead of %d\n", rotation, startmode.dmDisplayOrientation); -- 1.7.0.4