From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/d2d1/d2d1_private.h | 1 + dlls/d2d1/device.c | 15 +++++++++++++-- dlls/d2d1/tests/d2d1.c | 19 ++++--------------- 3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 58507fd2c0b..e9a279e4c7a 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -613,6 +613,7 @@ struct d2d_device LONG refcount; ID2D1Factory1 *factory; IDXGIDevice *dxgi_device; + BOOL allow_get_dxgi_device;
struct d2d_indexed_objects shaders; }; diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index ce0175966b1..ff2734d04bd 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -3992,6 +3992,9 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, goto err; }
+ if (!d2d_device_context_is_dxgi_target(render_target)) + device->allow_get_dxgi_device = FALSE; + if (FAILED(hr = ID3D11Device1_CreateDeviceContextState(render_target->d3d_device, 0, &feature_levels, 1, D3D11_SDK_VERSION, &IID_ID3D11Device1, NULL, &render_target->d3d_state))) @@ -4426,9 +4429,16 @@ static void STDMETHODCALLTYPE d2d_device_FlushDeviceContexts(ID2D1Device6 *iface static HRESULT STDMETHODCALLTYPE d2d_device_GetDxgiDevice(ID2D1Device6 *iface, IDXGIDevice **dxgi_device) { - FIXME("iface %p, dxgi_device %p stub!\n", iface, dxgi_device); + struct d2d_device *device = impl_from_ID2D1Device(iface);
- return E_NOTIMPL; + TRACE("iface %p, dxgi_device %p.\n", iface, dxgi_device); + + if (!device->allow_get_dxgi_device) + return D2DERR_INVALID_CALL; + + IDXGIDevice_AddRef(device->dxgi_device); + *dxgi_device = device->dxgi_device; + return S_OK; }
static HRESULT STDMETHODCALLTYPE d2d_device_ID2D1Device3_CreateDeviceContext(ID2D1Device6 *iface, @@ -4525,6 +4535,7 @@ void d2d_device_init(struct d2d_device *device, struct d2d_factory *factory, IDX ID2D1Factory1_AddRef(device->factory); device->dxgi_device = dxgi_device; IDXGIDevice_AddRef(device->dxgi_device); + device->allow_get_dxgi_device = TRUE; }
HRESULT d2d_device_add_indexed_object(struct d2d_indexed_objects *objects, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 011e1d51ccc..bc9d9f75935 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -15479,14 +15479,10 @@ static void test_get_dxgi_device(BOOL d3d11) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hr = ID2D1Device2_GetDxgiDevice(device2, &dxgi_device); - todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - if (hr == S_OK) - { - ok(dxgi_device == ctx.device, "Got unexpected IDXGIDevice.\n"); - IDXGIDevice_Release(dxgi_device); - } + ok(dxgi_device == ctx.device, "Got unexpected IDXGIDevice.\n");
+ IDXGIDevice_Release(dxgi_device); ID2D1Device2_Release(device2); ID2D1Device_Release(device);
@@ -15515,7 +15511,6 @@ static void test_get_dxgi_device(BOOL d3d11) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hr = ID2D1Device2_GetDxgiDevice(device2, &dxgi_device); - todo_wine ok(hr == D2DERR_INVALID_CALL, "Got unexpected hr %#lx.\n", hr);
ID2D1Device2_Release(device2); @@ -15549,7 +15544,6 @@ static void test_get_dxgi_device(BOOL d3d11) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hr = ID2D1Device2_GetDxgiDevice(device2, &dxgi_device); - todo_wine ok(hr == D2DERR_INVALID_CALL, "Got unexpected hr %#lx.\n", hr);
ID2D1Device2_Release(device2); @@ -15564,14 +15558,10 @@ static void test_get_dxgi_device(BOOL d3d11) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hr = ID2D1Device2_GetDxgiDevice(device2, &dxgi_device); - todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - if (hr == S_OK) - { - ok(dxgi_device == ctx.device, "Got unexpected IDXGIDevice.\n"); - IDXGIDevice_Release(dxgi_device); - } + ok(dxgi_device == ctx.device, "Got unexpected IDXGIDevice.\n");
+ IDXGIDevice_Release(dxgi_device); ID2D1Device2_Release(device2); ID2D1Device_Release(device);
@@ -15593,7 +15583,6 @@ static void test_get_dxgi_device(BOOL d3d11) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hr = ID2D1Device2_GetDxgiDevice(device2, &dxgi_device); - todo_wine ok(hr == D2DERR_INVALID_CALL, "Got unexpected hr %#lx.\n", hr);
ID2D1Device2_Release(device2);