[PATCH 3/6] d2d1: Query ID3D10Device1 interface on device creation.
Rémi Bernon
rbernon at codeweavers.com
Mon Jan 18 06:57:43 CST 2021
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/d2d1/d2d1_private.h | 1 +
dlls/d2d1/device.c | 18 ++++++++++++++----
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index 436c4b0f245..7211029d920 100644
--- a/dlls/d2d1/d2d1_private.h
+++ b/dlls/d2d1/d2d1_private.h
@@ -539,6 +539,7 @@ struct d2d_device
LONG refcount;
ID2D1Factory1 *factory;
IDXGIDevice *dxgi_device;
+ ID3D10Device *d3d10_device;
};
void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *factory, IDXGIDevice *dxgi_device) DECLSPEC_HIDDEN;
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c
index 5f04c3aa833..3c33fba0e56 100644
--- a/dlls/d2d1/device.c
+++ b/dlls/d2d1/device.c
@@ -3875,13 +3875,13 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target,
render_target->ops = ops;
device_impl = unsafe_impl_from_ID2D1Device(device);
- if (FAILED(hr = IDXGIDevice_QueryInterface(device_impl->dxgi_device,
- &IID_ID3D10Device, (void **)&render_target->d3d_device)))
+ if (!device_impl->d3d10_device)
{
- WARN("Failed to get device interface, hr %#x.\n", hr);
+ WARN("Failed to get device interface.\n");
ID2D1Factory_Release(render_target->factory);
- return hr;
+ return E_NOINTERFACE;
}
+ ID3D10Device_AddRef(render_target->d3d_device = device_impl->d3d10_device);
if (FAILED(hr = D3D10StateBlockMaskEnableAll(&state_mask)))
{
@@ -4126,6 +4126,7 @@ static ULONG WINAPI d2d_device_Release(ID2D1Device *iface)
if (!refcount)
{
+ if (device->d3d10_device) ID3D10Device_Release(device->d3d10_device);
IDXGIDevice_Release(device->dxgi_device);
ID2D1Factory1_Release(device->factory);
heap_free(device);
@@ -4223,10 +4224,19 @@ static struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device *iface)
void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *iface, IDXGIDevice *dxgi_device)
{
+ HRESULT hr;
+
device->ID2D1Device_iface.lpVtbl = &d2d_device_vtbl;
device->refcount = 1;
device->factory = iface;
ID2D1Factory1_AddRef(device->factory);
device->dxgi_device = dxgi_device;
IDXGIDevice_AddRef(device->dxgi_device);
+
+ if (FAILED(hr = IDXGIDevice_QueryInterface(device->dxgi_device,
+ &IID_ID3D10Device, (void **)&device->d3d10_device)))
+ {
+ WARN("Failed to get device interface, hr %#x.\n", hr);
+ device->d3d10_device = NULL;
+ }
}
--
2.30.0
More information about the wine-devel
mailing list