From: Vladislav Timonin timoninvlad@yandex.ru
--- dlls/d2d1/d2d1_private.h | 12 ++--- dlls/d2d1/dc_render_target.c | 8 +-- dlls/d2d1/device.c | 89 +++++++++++++++++++++++----------- dlls/d2d1/factory.c | 59 ++++++++++++---------- dlls/d2d1/hwnd_render_target.c | 10 ++-- dlls/d2d1/tests/d2d1.c | 52 ++++++++++++++++++++ dlls/d2d1/wic_render_target.c | 8 +-- 7 files changed, 166 insertions(+), 72 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 085febe95e7..15af817ab41 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -171,7 +171,7 @@ struct d2d_device_context const struct d2d_device_context_ops *ops;
ID2D1Factory *factory; - ID2D1Device *device; + ID2D1Device1 *device; ID3D11Device1 *d3d_device; ID3DDeviceContextState *d3d_state; struct @@ -208,7 +208,7 @@ struct d2d_device_context struct d2d_clip_stack clip_stack; };
-HRESULT d2d_d3d_create_render_target(ID2D1Device *device, IDXGISurface *surface, IUnknown *outer_unknown, +HRESULT d2d_d3d_create_render_target(ID2D1Device1 *device, IDXGISurface *surface, IUnknown *outer_unknown, const struct d2d_device_context_ops *ops, const D2D1_RENDER_TARGET_PROPERTIES *desc, void **render_target) DECLSPEC_HIDDEN;
@@ -233,7 +233,7 @@ struct d2d_wic_render_target unsigned int bpp; };
-HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target, ID2D1Factory1 *factory, +HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target, ID2D1Factory2 *factory, ID3D10Device1 *d3d_device, IWICBitmap *bitmap, const D2D1_RENDER_TARGET_PROPERTIES *desc) DECLSPEC_HIDDEN;
struct d2d_dc_render_target @@ -251,7 +251,7 @@ struct d2d_dc_render_target HDC hdc; };
-HRESULT d2d_dc_render_target_init(struct d2d_dc_render_target *render_target, ID2D1Factory1 *factory, +HRESULT d2d_dc_render_target_init(struct d2d_dc_render_target *render_target, ID2D1Factory2 *factory, ID3D10Device1 *d3d_device, const D2D1_RENDER_TARGET_PROPERTIES *desc) DECLSPEC_HIDDEN;
struct d2d_hwnd_render_target @@ -266,7 +266,7 @@ struct d2d_hwnd_render_target HWND hwnd; };
-HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target, ID2D1Factory1 *factory, +HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target, ID2D1Factory2 *factory, ID3D10Device1 *d3d_device, const D2D1_RENDER_TARGET_PROPERTIES *desc, const D2D1_HWND_RENDER_TARGET_PROPERTIES *hwnd_desc) DECLSPEC_HIDDEN;
@@ -590,7 +590,7 @@ struct d2d_geometry *unsafe_impl_from_ID2D1Geometry(ID2D1Geometry *iface) DECLSP
struct d2d_device { - ID2D1Device ID2D1Device_iface; + ID2D1Device1 ID2D1Device1_iface; LONG refcount; ID2D1Factory1 *factory; IDXGIDevice *dxgi_device; diff --git a/dlls/d2d1/dc_render_target.c b/dlls/d2d1/dc_render_target.c index 30eafe361d1..afc6009bac9 100644 --- a/dlls/d2d1/dc_render_target.c +++ b/dlls/d2d1/dc_render_target.c @@ -800,11 +800,11 @@ static const struct d2d_device_context_ops d2d_dc_render_target_ops = d2d_dc_render_target_present, };
-HRESULT d2d_dc_render_target_init(struct d2d_dc_render_target *render_target, ID2D1Factory1 *factory, +HRESULT d2d_dc_render_target_init(struct d2d_dc_render_target *render_target, ID2D1Factory2 *factory, ID3D10Device1 *d3d_device, const D2D1_RENDER_TARGET_PROPERTIES *desc) { IDXGIDevice *dxgi_device; - ID2D1Device *device; + ID2D1Device1 *device; HRESULT hr;
render_target->ID2D1DCRenderTarget_iface.lpVtbl = &d2d_dc_render_target_vtbl; @@ -832,7 +832,7 @@ HRESULT d2d_dc_render_target_init(struct d2d_dc_render_target *render_target, ID return hr; }
- hr = ID2D1Factory1_CreateDevice(factory, dxgi_device, &device); + hr = ID2D1Factory2_CreateDevice(factory, dxgi_device, &device); IDXGIDevice_Release(dxgi_device); if (FAILED(hr)) { @@ -842,7 +842,7 @@ HRESULT d2d_dc_render_target_init(struct d2d_dc_render_target *render_target, ID
hr = d2d_d3d_create_render_target(device, NULL, (IUnknown *)&render_target->ID2D1DCRenderTarget_iface, &d2d_dc_render_target_ops, desc, (void **)&render_target->dxgi_inner); - ID2D1Device_Release(device); + ID2D1Device1_Release(device); if (FAILED(hr)) { WARN("Failed to create DXGI surface render target, hr %#lx.\n", hr); diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 32519f662c9..c68862dc1d2 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -35,12 +35,12 @@ struct d2d_draw_text_layout_ctx D2D1_DRAW_TEXT_OPTIONS options; };
-static inline struct d2d_device *impl_from_ID2D1Device(ID2D1Device *iface) +static inline struct d2d_device *impl_from_ID2D1Device(ID2D1Device1 *iface) { - return CONTAINING_RECORD(iface, struct d2d_device, ID2D1Device_iface); + return CONTAINING_RECORD(iface, struct d2d_device, ID2D1Device1_iface); }
-static struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device *iface); +static struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device1 *iface);
static ID2D1Brush *d2d_draw_get_text_brush(struct d2d_draw_text_layout_ctx *context, IUnknown *effect) { @@ -293,7 +293,7 @@ static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface) IUnknown_Release(context->target.object); ID3D11Device1_Release(context->d3d_device); ID2D1Factory_Release(context->factory); - ID2D1Device_Release(context->device); + ID2D1Device1_Release(context->device); free(context); }
@@ -2336,8 +2336,8 @@ static void STDMETHODCALLTYPE d2d_device_context_GetDevice(ID2D1DeviceContext1 *
TRACE("iface %p, device %p.\n", iface, device);
- *device = context->device; - ID2D1Device_AddRef(*device); + *device = (ID2D1Device *)context->device; + ID2D1Device1_AddRef((ID2D1Device1 *)*device); }
static void d2d_device_context_reset_target(struct d2d_device_context *context) @@ -3167,7 +3167,7 @@ static const struct ID2D1GdiInteropRenderTargetVtbl d2d_gdi_interop_render_targe d2d_gdi_interop_render_target_ReleaseDC, };
-static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, ID2D1Device *device, +static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, ID2D1Device1 *device, IUnknown *outer_unknown, const struct d2d_device_context_ops *ops) { D3D11_SUBRESOURCE_DATA buffer_data; @@ -4231,9 +4231,9 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, render_target->IDWriteTextRenderer_iface.lpVtbl = &d2d_text_renderer_vtbl; render_target->IUnknown_iface.lpVtbl = &d2d_device_context_inner_unknown_vtbl; render_target->refcount = 1; - ID2D1Device_GetFactory(device, &render_target->factory); + ID2D1Device1_GetFactory(device, &render_target->factory); render_target->device = device; - ID2D1Device_AddRef(render_target->device); + ID2D1Device1_AddRef(render_target->device);
render_target->outer_unknown = outer_unknown ? outer_unknown : &render_target->IUnknown_iface; render_target->ops = ops; @@ -4407,12 +4407,12 @@ err: ID3DDeviceContextState_Release(render_target->d3d_state); if (render_target->d3d_device) ID3D11Device1_Release(render_target->d3d_device); - ID2D1Device_Release(render_target->device); + ID2D1Device1_Release(render_target->device); ID2D1Factory_Release(render_target->factory); return hr; }
-HRESULT d2d_d3d_create_render_target(ID2D1Device *device, IDXGISurface *surface, IUnknown *outer_unknown, +HRESULT d2d_d3d_create_render_target(ID2D1Device1 *device, IDXGISurface *surface, IUnknown *outer_unknown, const struct d2d_device_context_ops *ops, const D2D1_RENDER_TARGET_PROPERTIES *desc, void **render_target) { D2D1_BITMAP_PROPERTIES1 bitmap_desc; @@ -4477,15 +4477,16 @@ HRESULT d2d_d3d_create_render_target(ID2D1Device *device, IDXGISurface *surface, return S_OK; }
-static HRESULT WINAPI d2d_device_QueryInterface(ID2D1Device *iface, REFIID iid, void **out) +static HRESULT WINAPI d2d_device_QueryInterface(ID2D1Device1 *iface, REFIID iid, void **out) { TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
- if (IsEqualGUID(iid, &IID_ID2D1Device) + if (IsEqualGUID(iid, &IID_ID2D1Device1) + || IsEqualGUID(iid, &IID_ID2D1Device) || IsEqualGUID(iid, &IID_ID2D1Resource) || IsEqualGUID(iid, &IID_IUnknown)) { - ID2D1Device_AddRef(iface); + ID2D1Device1_AddRef(iface); *out = iface; return S_OK; } @@ -4496,7 +4497,7 @@ static HRESULT WINAPI d2d_device_QueryInterface(ID2D1Device *iface, REFIID iid, return E_NOINTERFACE; }
-static ULONG WINAPI d2d_device_AddRef(ID2D1Device *iface) +static ULONG WINAPI d2d_device_AddRef(ID2D1Device1 *iface) { struct d2d_device *device = impl_from_ID2D1Device(iface); ULONG refcount = InterlockedIncrement(&device->refcount); @@ -4506,7 +4507,7 @@ static ULONG WINAPI d2d_device_AddRef(ID2D1Device *iface) return refcount; }
-static ULONG WINAPI d2d_device_Release(ID2D1Device *iface) +static ULONG WINAPI d2d_device_Release(ID2D1Device1 *iface) { struct d2d_device *device = impl_from_ID2D1Device(iface); ULONG refcount = InterlockedDecrement(&device->refcount); @@ -4523,7 +4524,7 @@ static ULONG WINAPI d2d_device_Release(ID2D1Device *iface) return refcount; }
-static void WINAPI d2d_device_GetFactory(ID2D1Device *iface, ID2D1Factory **factory) +static void WINAPI d2d_device_GetFactory(ID2D1Device1 *iface, ID2D1Factory **factory) { struct d2d_device *device = impl_from_ID2D1Device(iface);
@@ -4533,8 +4534,8 @@ static void WINAPI d2d_device_GetFactory(ID2D1Device *iface, ID2D1Factory **fact ID2D1Factory1_AddRef(device->factory); }
-static HRESULT WINAPI d2d_device_CreateDeviceContext(ID2D1Device *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, - ID2D1DeviceContext **context) +static HRESULT WINAPI d2d_device_CreateDeviceContext1(ID2D1Device1 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, + ID2D1DeviceContext1 **context) { struct d2d_device_context *object; HRESULT hr; @@ -4555,12 +4556,29 @@ static HRESULT WINAPI d2d_device_CreateDeviceContext(ID2D1Device *iface, D2D1_DE }
TRACE("Created device context %p.\n", object); - *context = (ID2D1DeviceContext *)&object->ID2D1DeviceContext1_iface; + *context = &object->ID2D1DeviceContext1_iface;
return S_OK; }
-static HRESULT WINAPI d2d_device_CreatePrintControl(ID2D1Device *iface, IWICImagingFactory *wic_factory, +static HRESULT WINAPI d2d_device_CreateDeviceContext(ID2D1Device1 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, + ID2D1DeviceContext **context) +{ + ID2D1DeviceContext1 *context1 = NULL; + HRESULT hr; + + TRACE("iface %p, options %#x, context %p.\n", iface, options, context); + + if (FAILED(hr = d2d_device_CreateDeviceContext1(iface, options, &context1))) { + return hr; + } + + *context = (ID2D1DeviceContext *)context1; + + return S_OK; +} + +static HRESULT WINAPI d2d_device_CreatePrintControl(ID2D1Device1 *iface, IWICImagingFactory *wic_factory, IPrintDocumentPackageTarget *document_target, const D2D1_PRINT_CONTROL_PROPERTIES *desc, ID2D1PrintControl **print_control) { @@ -4570,26 +4588,38 @@ static HRESULT WINAPI d2d_device_CreatePrintControl(ID2D1Device *iface, IWICImag return E_NOTIMPL; }
-static void WINAPI d2d_device_SetMaximumTextureMemory(ID2D1Device *iface, UINT64 max_texture_memory) +static void WINAPI d2d_device_SetMaximumTextureMemory(ID2D1Device1 *iface, UINT64 max_texture_memory) { FIXME("iface %p, max_texture_memory %s stub!\n", iface, wine_dbgstr_longlong(max_texture_memory)); }
-static UINT64 WINAPI d2d_device_GetMaximumTextureMemory(ID2D1Device *iface) +static UINT64 WINAPI d2d_device_GetMaximumTextureMemory(ID2D1Device1 *iface) { FIXME("iface %p stub!\n", iface);
return 0; }
-static HRESULT WINAPI d2d_device_ClearResources(ID2D1Device *iface, UINT msec_since_use) +static HRESULT WINAPI d2d_device_ClearResources(ID2D1Device1 *iface, UINT msec_since_use) { FIXME("iface %p, msec_since_use %u stub!\n", iface, msec_since_use);
return E_NOTIMPL; }
-static const struct ID2D1DeviceVtbl d2d_device_vtbl = +static D2D1_RENDERING_PRIORITY WINAPI d2d_device_GetRenderingPriority(ID2D1Device1 *iface) +{ + FIXME("iface %p, stub, returning D2D1_RENDERING_PRIORITY_NORMAL!\n", iface); + + return D2D1_RENDERING_PRIORITY_NORMAL; +} + +static void WINAPI d2d_device_SetRenderingPriority(ID2D1Device1 *iface, D2D1_RENDERING_PRIORITY priority) +{ + FIXME("iface %p, priority %#x stub!\n", iface, priority); +} + +static const struct ID2D1Device1Vtbl d2d_device_vtbl = { d2d_device_QueryInterface, d2d_device_AddRef, @@ -4600,19 +4630,22 @@ static const struct ID2D1DeviceVtbl d2d_device_vtbl = d2d_device_SetMaximumTextureMemory, d2d_device_GetMaximumTextureMemory, d2d_device_ClearResources, + d2d_device_GetRenderingPriority, + d2d_device_SetRenderingPriority, + d2d_device_CreateDeviceContext1, };
-static struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device *iface) +static struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device1 *iface) { if (!iface) return NULL; assert(iface->lpVtbl == &d2d_device_vtbl); - return CONTAINING_RECORD(iface, struct d2d_device, ID2D1Device_iface); + return CONTAINING_RECORD(iface, struct d2d_device, ID2D1Device1_iface); }
void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *iface, IDXGIDevice *dxgi_device) { - device->ID2D1Device_iface.lpVtbl = &d2d_device_vtbl; + device->ID2D1Device1_iface.lpVtbl = &d2d_device_vtbl; device->refcount = 1; device->factory = iface; ID2D1Factory1_AddRef(device->factory); diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c index a160d7071c2..5dc571ad257 100644 --- a/dlls/d2d1/factory.c +++ b/dlls/d2d1/factory.c @@ -429,7 +429,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateWicBitmapRenderTarget(ID2D1Fa return hr; }
- if (FAILED(hr = d2d_wic_render_target_init(object, (ID2D1Factory1 *)iface, device, target, desc))) + if (FAILED(hr = d2d_wic_render_target_init(object, (ID2D1Factory2 *)iface, device, target, desc))) { WARN("Failed to initialise render target, hr %#lx.\n", hr); free(object); @@ -459,7 +459,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateHwndRenderTarget(ID2D1Factory if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
- if (FAILED(hr = d2d_hwnd_render_target_init(object, (ID2D1Factory1 *)iface, device, desc, hwnd_rt_desc))) + if (FAILED(hr = d2d_hwnd_render_target_init(object, (ID2D1Factory2 *)iface, device, desc, hwnd_rt_desc))) { WARN("Failed to initialise render target, hr %#lx.\n", hr); free(object); @@ -476,7 +476,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDxgiSurfaceRenderTarget(ID2D1 IDXGISurface *surface, const D2D1_RENDER_TARGET_PROPERTIES *desc, ID2D1RenderTarget **render_target) { IDXGIDevice *dxgi_device; - ID2D1Device *device; + ID2D1Device1 *device; HRESULT hr;
TRACE("iface %p, surface %p, desc %p, render_target %p.\n", iface, surface, desc, render_target); @@ -487,7 +487,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDxgiSurfaceRenderTarget(ID2D1 return hr; }
- hr = ID2D1Factory1_CreateDevice((ID2D1Factory1 *)iface, dxgi_device, &device); + hr = ID2D1Factory2_CreateDevice((ID2D1Factory2 *)iface, dxgi_device, &device); IDXGIDevice_Release(dxgi_device); if (FAILED(hr)) { @@ -496,7 +496,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDxgiSurfaceRenderTarget(ID2D1 }
hr = d2d_d3d_create_render_target(device, surface, NULL, NULL, desc, (void **)render_target); - ID2D1Device_Release(device); + ID2D1Device1_Release(device); return hr; }
@@ -516,7 +516,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDCRenderTarget(ID2D1Factory3 if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
- if (FAILED(hr = d2d_dc_render_target_init(object, (ID2D1Factory1 *)iface, device, desc))) + if (FAILED(hr = d2d_dc_render_target_init(object, (ID2D1Factory2 *)iface, device, desc))) { WARN("Failed to initialise render target, hr %#lx.\n", hr); free(object); @@ -529,8 +529,16 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDCRenderTarget(ID2D1Factory3 return S_OK; }
-static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDevice(ID2D1Factory3 *iface, - IDXGIDevice *dxgi_device, ID2D1Device **device) +static HRESULT STDMETHODCALLTYPE d2d_factory_ID2D1Factory3_CreateDevice(ID2D1Factory3 *iface, IDXGIDevice *dxgi_device, + ID2D1Device2 **device) +{ + FIXME("iface %p, dxgi_device %p, device %p stub!\n", iface, dxgi_device, device); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_factory_ID2D1Factory2_CreateDevice(ID2D1Factory3 *iface, IDXGIDevice *dxgi_device, + ID2D1Device1 **device) { struct d2d_device *object;
@@ -542,7 +550,24 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDevice(ID2D1Factory3 *iface, d2d_device_init(object, (ID2D1Factory1 *)iface, dxgi_device);
TRACE("Create device %p.\n", object); - *device = &object->ID2D1Device_iface; + *device = &object->ID2D1Device1_iface; + + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDevice(ID2D1Factory3 *iface, + IDXGIDevice *dxgi_device, ID2D1Device **device) +{ + ID2D1Device1 *device1 = NULL; + HRESULT hr; + + TRACE("iface %p, dxgi_device %p, device %p.\n", iface, dxgi_device, device); + + if (FAILED(hr = d2d_factory_ID2D1Factory2_CreateDevice(iface, dxgi_device, &device1))) { + return hr; + } + + *device = (ID2D1Device*)device1;
return S_OK; } @@ -1077,22 +1102,6 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_GetEffectProperties(ID2D1Factory3 * return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE d2d_factory_ID2D1Factory2_CreateDevice(ID2D1Factory3 *iface, IDXGIDevice *dxgi_device, - ID2D1Device1 **device) -{ - FIXME("iface %p, dxgi_device %p, device %p stub!\n", iface, dxgi_device, device); - - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE d2d_factory_ID2D1Factory3_CreateDevice(ID2D1Factory3 *iface, IDXGIDevice *dxgi_device, - ID2D1Device2 **device) -{ - FIXME("iface %p, dxgi_device %p, device %p stub!\n", iface, dxgi_device, device); - - return E_NOTIMPL; -} - static const struct ID2D1Factory3Vtbl d2d_factory_vtbl = { d2d_factory_QueryInterface, diff --git a/dlls/d2d1/hwnd_render_target.c b/dlls/d2d1/hwnd_render_target.c index 5338ca3383f..fdf9cf2e2f7 100644 --- a/dlls/d2d1/hwnd_render_target.c +++ b/dlls/d2d1/hwnd_render_target.c @@ -788,7 +788,7 @@ static const struct d2d_device_context_ops d2d_hwnd_render_target_ops = d2d_hwnd_render_target_present, };
-HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target, ID2D1Factory1 *factory, +HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target, ID2D1Factory2 *factory, ID3D10Device1 *d3d_device, const D2D1_RENDER_TARGET_PROPERTIES *desc, const D2D1_HWND_RENDER_TARGET_PROPERTIES *hwnd_rt_desc) { @@ -798,7 +798,7 @@ HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target IDXGIFactory *dxgi_factory; IDXGISurface *dxgi_surface; IDXGIDevice *dxgi_device; - ID2D1Device *device; + ID2D1Device1 *device; HRESULT hr;
if (!IsWindow(hwnd_rt_desc->hwnd)) @@ -832,7 +832,7 @@ HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target
dxgi_rt_desc = *desc; if (dxgi_rt_desc.dpiX == 0.0f && dxgi_rt_desc.dpiY == 0.0f) - ID2D1Factory1_GetDesktopDpi(factory, &dxgi_rt_desc.dpiX, &dxgi_rt_desc.dpiY); + ID2D1Factory2_GetDesktopDpi(factory, &dxgi_rt_desc.dpiX, &dxgi_rt_desc.dpiY);
if (dxgi_rt_desc.pixelFormat.format == DXGI_FORMAT_UNKNOWN) { @@ -882,7 +882,7 @@ HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target return hr; }
- hr = ID2D1Factory1_CreateDevice(factory, dxgi_device, &device); + hr = ID2D1Factory2_CreateDevice(factory, dxgi_device, &device); IDXGIDevice_Release(dxgi_device); if (FAILED(hr)) { @@ -896,7 +896,7 @@ HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target (IUnknown *)&render_target->ID2D1HwndRenderTarget_iface, &d2d_hwnd_render_target_ops, &dxgi_rt_desc, (void **)&render_target->dxgi_inner); IDXGISurface_Release(dxgi_surface); - ID2D1Device_Release(device); + ID2D1Device1_Release(device); if (FAILED(hr)) { WARN("Failed to create DXGI surface render target, hr %#lx.\n", hr); diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 3bfc8973c31..39e5eba7123 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -9139,6 +9139,57 @@ static void test_bitmap_surface(BOOL d3d11) release_test_context(&ctx); }
+static void test_device_context_constructors(BOOL d3d11) +{ + ID2D1DeviceContext *device_context; + ID2D1DeviceContext1 *device_context1; + ID2D1Device *device; + ID2D1Device1 *device1; + struct d2d1_test_context ctx; + ID2D1Factory1 *factory1; + ID2D1Factory2 *factory2; + HRESULT hr; + + if (!init_test_context(&ctx, d3d11)) + return; + + if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory1))) + { + win_skip("ID2D1Factory1 is not supported.\n"); + release_test_context(&ctx); + return; + } + + hr = ID2D1Factory1_CreateDevice(factory1, ctx.device, &device); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = ID2D1Device_CreateDeviceContext(device, D2D1_DEVICE_CONTEXT_OPTIONS_NONE, &device_context); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + ID2D1DeviceContext_Release(device_context); + ID2D1Device_Release(device); + ID2D1Factory1_Release(factory1); + + if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory2, NULL, (void **)&factory2))) + { + win_skip("ID2D1Factory2 is not supported.\n"); + release_test_context(&ctx); + return; + } + + hr = ID2D1Factory2_CreateDevice(factory2, ctx.device, &device1); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = ID2D1Device1_CreateDeviceContext(device1, D2D1_DEVICE_CONTEXT_OPTIONS_NONE, &device_context1); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + ID2D1DeviceContext1_Release(device_context1); + ID2D1Device1_Release(device1); + ID2D1Factory2_Release(factory2); + + release_test_context(&ctx); +} + static void test_device_context(BOOL d3d11) { D2D1_HWND_RENDER_TARGET_PROPERTIES hwnd_rt_desc; @@ -13275,6 +13326,7 @@ START_TEST(d2d1) queue_test(test_bezier_intersect); queue_test(test_create_device); queue_test(test_bitmap_surface); + queue_test(test_device_context_constructors); queue_test(test_device_context); queue_d3d10_test(test_invert_matrix); queue_d3d10_test(test_skew_matrix); diff --git a/dlls/d2d1/wic_render_target.c b/dlls/d2d1/wic_render_target.c index f6e7b14ed3f..e87fda93fee 100644 --- a/dlls/d2d1/wic_render_target.c +++ b/dlls/d2d1/wic_render_target.c @@ -149,13 +149,13 @@ static const struct d2d_device_context_ops d2d_wic_render_target_ops = d2d_wic_render_target_present, };
-HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target, ID2D1Factory1 *factory, +HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target, ID2D1Factory2 *factory, ID3D10Device1 *d3d_device, IWICBitmap *bitmap, const D2D1_RENDER_TARGET_PROPERTIES *desc) { D3D10_TEXTURE2D_DESC texture_desc; ID3D10Texture2D *texture; IDXGIDevice *dxgi_device; - ID2D1Device *device; + ID2D1Device1 *device; HRESULT hr;
render_target->IUnknown_iface.lpVtbl = &d2d_wic_render_target_vtbl; @@ -246,7 +246,7 @@ HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target, return hr; }
- hr = ID2D1Factory1_CreateDevice(factory, dxgi_device, &device); + hr = ID2D1Factory2_CreateDevice(factory, dxgi_device, &device); IDXGIDevice_Release(dxgi_device); if (FAILED(hr)) { @@ -257,7 +257,7 @@ HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target,
hr = d2d_d3d_create_render_target(device, render_target->dxgi_surface, &render_target->IUnknown_iface, &d2d_wic_render_target_ops, desc, (void **)&render_target->dxgi_inner); - ID2D1Device_Release(device); + ID2D1Device1_Release(device); if (FAILED(hr)) { WARN("Failed to create DXGI surface render target, hr %#lx.\n", hr);
Nikolay Sivov (@nsivov) commented about dlls/d2d1/tests/d2d1.c:
- ID2D1Device *device;
- ID2D1Device1 *device1;
- struct d2d1_test_context ctx;
- ID2D1Factory1 *factory1;
- ID2D1Factory2 *factory2;
- HRESULT hr;
- if (!init_test_context(&ctx, d3d11))
return;
- if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory1)))
- {
win_skip("ID2D1Factory1 is not supported.\n");
release_test_context(&ctx);
return;
- }
I understand this is copied from some existing test, but all you need here is to check ctx.factory1 and skip, without creating another factory.
Nikolay Sivov (@nsivov) commented about dlls/d2d1/tests/d2d1.c:
release_test_context(&ctx);
}
+static void test_device_context_constructors(BOOL d3d11)
This new section could as well live in existing test_device_context().
Nikolay Sivov (@nsivov) commented about dlls/d2d1/d2d1_private.h:
struct d2d_clip_stack clip_stack;
};
-HRESULT d2d_d3d_create_render_target(ID2D1Device *device, IDXGISurface *surface, IUnknown *outer_unknown, +HRESULT d2d_d3d_create_render_target(ID2D1Device1 *device, IDXGISurface *surface, IUnknown *outer_unknown,
Is there really a need to update that much of internal helpers? I think all you need is to extend device vtbl with new methods, and implement newer factory method that returns Device1 interface.
Nikolay Sivov (@nsivov) commented about dlls/d2d1/factory.c:
ID2D1Device1 **device)
-{
- FIXME("iface %p, dxgi_device %p, device %p stub!\n", iface, dxgi_device, device);
- return E_NOTIMPL;
-}
-static HRESULT STDMETHODCALLTYPE d2d_factory_ID2D1Factory3_CreateDevice(ID2D1Factory3 *iface, IDXGIDevice *dxgi_device,
ID2D1Device2 **device)
-{
- FIXME("iface %p, dxgi_device %p, device %p stub!\n", iface, dxgi_device, device);
- return E_NOTIMPL;
-}
static const struct ID2D1Factory3Vtbl d2d_factory_vtbl =
Let's not rearrange function order, I would add a new function d2d_device_create() that takes dxgi device and returns "struct d2d_device *", you can use that function in all CreateDevice methods, keeping their own trace messages without duplicating them in debug output.
Nikolay Sivov (@nsivov) commented about dlls/d2d1/device.c:
+static HRESULT WINAPI d2d_device_CreateDeviceContext(ID2D1Device1 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options,
ID2D1DeviceContext **context)
+{
- ID2D1DeviceContext1 *context1 = NULL;
- HRESULT hr;
- TRACE("iface %p, options %#x, context %p.\n", iface, options, context);
- if (FAILED(hr = d2d_device_CreateDeviceContext1(iface, options, &context1))) {
return hr;
- }
- *context = (ID2D1DeviceContext *)context1;
- return S_OK;
+}
Let's split this up, first add what's necessary to extend to ID2D1Device1, and then implement new CreateDeviceContext1 with a separate commit.