[PATCH 1/2] d2d1: Add ID2D1Device stub.
Nikolay Sivov
nsivov at codeweavers.com
Tue May 15 05:21:46 CDT 2018
From: Lucian Poston <lucian.poston at gmail.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
Comparing to what's in staging now, I renamed some things for consistency,
and used existing source file. Same for device context, I think we should
consider using render_target.c for it, or rename it to devicecontext.c.
dlls/d2d1/factory.c | 143 +++++++++++++++++++++++++++++++++++++++++++-
include/d2d1_1.idl | 61 ++++++++++++++++++-
2 files changed, 201 insertions(+), 3 deletions(-)
diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c
index 9bacc8583c..1ea27614e4 100644
--- a/dlls/d2d1/factory.c
+++ b/dlls/d2d1/factory.c
@@ -30,6 +30,135 @@ struct d2d_settings d2d_settings =
~0u, /* No ID2D1Factory version limit by default. */
};
+struct d2d_device
+{
+ ID2D1Device ID2D1Device_iface;
+ LONG refcount;
+ ID2D1Factory1 *factory;
+ IDXGIDevice *dxgi_device;
+};
+
+static inline struct d2d_device *impl_from_ID2D1Device(ID2D1Device *iface)
+{
+ return CONTAINING_RECORD(iface, struct d2d_device, ID2D1Device_iface);
+}
+
+static HRESULT WINAPI d2d_device_QueryInterface(ID2D1Device *iface, REFIID riid, void **out)
+{
+ TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
+
+ if (IsEqualGUID(riid, &IID_ID2D1Device)
+ || IsEqualGUID(riid, &IID_ID2D1Resource)
+ || IsEqualGUID(riid, &IID_IUnknown))
+ {
+ ID2D1Device_AddRef(iface);
+ *out = iface;
+ return S_OK;
+ }
+
+ WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
+
+ *out = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI d2d_device_AddRef(ID2D1Device *iface)
+{
+ struct d2d_device *device = impl_from_ID2D1Device(iface);
+ ULONG refcount = InterlockedIncrement(&device->refcount);
+
+ TRACE("%p increasing refcount to %u.\n", iface, refcount);
+
+ return refcount;
+}
+
+static ULONG WINAPI d2d_device_Release(ID2D1Device *iface)
+{
+ struct d2d_device *device = impl_from_ID2D1Device(iface);
+ ULONG refcount = InterlockedDecrement(&device->refcount);
+
+ TRACE("%p decreasing refcount to %u.\n", iface, refcount);
+
+ if (refcount == 0)
+ {
+ IDXGIDevice_Release(device->dxgi_device);
+ ID2D1Factory1_Release(device->factory);
+ heap_free(device);
+ }
+
+ return refcount;
+}
+
+static void WINAPI d2d_device_GetFactory(ID2D1Device *iface, ID2D1Factory **factory)
+{
+ struct d2d_device *device = impl_from_ID2D1Device(iface);
+
+ TRACE("iface %p, factory %p.\n", iface, factory);
+
+ *factory = (ID2D1Factory *)device->factory;
+ ID2D1Factory1_AddRef(device->factory);
+}
+
+static HRESULT WINAPI d2d_device_CreateDeviceContext(ID2D1Device *iface, D2D1_DEVICE_CONTEXT_OPTIONS options,
+ ID2D1DeviceContext **context)
+{
+ FIXME("iface %p, options %#x, context %p stub!\n", iface, options, context);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI d2d_device_CreatePrintControl(ID2D1Device *iface, IWICImagingFactory *wic_factory,
+ IPrintDocumentPackageTarget *document_target, const D2D1_PRINT_CONTROL_PROPERTIES *desc,
+ ID2D1PrintControl **print_control)
+{
+ FIXME("iface %p, wic_factory %p, document_target %p, desc %p, print_control %p stub!\n", iface, wic_factory,
+ document_target, desc, print_control);
+
+ return E_NOTIMPL;
+}
+
+static void WINAPI d2d_device_SetMaximumTextureMemory(ID2D1Device *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)
+{
+ FIXME("iface %p stub!\n", iface);
+
+ return 0;
+}
+
+static HRESULT WINAPI d2d_device_ClearResources(ID2D1Device *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 =
+{
+ d2d_device_QueryInterface,
+ d2d_device_AddRef,
+ d2d_device_Release,
+ d2d_device_GetFactory,
+ d2d_device_CreateDeviceContext,
+ d2d_device_CreatePrintControl,
+ d2d_device_SetMaximumTextureMemory,
+ d2d_device_GetMaximumTextureMemory,
+ d2d_device_ClearResources,
+};
+
+static void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *iface, IDXGIDevice *dxgi_device)
+{
+ 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);
+}
+
struct d2d_factory
{
ID2D1Factory1 ID2D1Factory1_iface;
@@ -375,9 +504,19 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDCRenderTarget(ID2D1Factory1
static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDevice(ID2D1Factory1 *iface,
IDXGIDevice *dxgi_device, ID2D1Device **device)
{
- FIXME("iface %p, dxgi_device %p, device %p stub!\n", iface, dxgi_device, device);
+ struct d2d_device *object;
- return E_NOTIMPL;
+ TRACE("iface %p, dxgi_device %p, device %p.\n", iface, dxgi_device, device);
+
+ if (!(object = heap_alloc_zero(sizeof(*object))))
+ return E_OUTOFMEMORY;
+
+ d2d_device_init(object, iface, dxgi_device);
+
+ TRACE("Create device %p.\n", object);
+ *device = &object->ID2D1Device_iface;
+
+ return S_OK;
}
static HRESULT STDMETHODCALLTYPE d2d_factory_CreateStrokeStyle1(ID2D1Factory1 *iface,
diff --git a/include/d2d1_1.idl b/include/d2d1_1.idl
index 1fbbb301dd..8f8b40b1d9 100644
--- a/include/d2d1_1.idl
+++ b/include/d2d1_1.idl
@@ -18,12 +18,22 @@
import "d2d1.idl";
-interface ID2D1Device;
+interface ID2D1DeviceContext;
interface ID2D1StrokeStyle1;
interface ID2D1PathGeometry1;
interface ID2D1DrawingStateBlock1;
interface ID2D1GdiMetafile;
interface ID2D1Properties;
+interface IPrintDocumentPackageTarget;
+interface ID2D1PrintControl;
+interface IWICImagingFactory;
+
+typedef enum D2D1_DEVICE_CONTEXT_OPTIONS
+{
+ D2D1_DEVICE_CONTEXT_OPTIONS_NONE = 0,
+ D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS = 1,
+ D2D1_DEVICE_CONTEXT_OPTIONS_FORCE_DWORD = 0xffffffff,
+} D2D1_DEVICE_CONTEXT_OPTIONS;
typedef enum D2D1_STROKE_TRANSFORM_TYPE
{
@@ -77,6 +87,55 @@ typedef struct D2D1_DRAWING_STATE_DESCRIPTION1
typedef HRESULT (__stdcall *PD2D1_EFFECT_FACTORY)(IUnknown **effect);
+typedef enum D2D1_PRINT_FONT_SUBSET_MODE
+{
+ D2D1_PRINT_FONT_SUBSET_MODE_DEFAULT = 0,
+ D2D1_PRINT_FONT_SUBSET_MODE_EACHPAGE = 1,
+ D2D1_PRINT_FONT_SUBSET_MODE_NONE = 2,
+ D2D1_PRINT_FONT_SUBSET_MODE_FORCE_DWORD = 0xffffffff,
+} D2D1_PRINT_FONT_SUBSET_MODE;
+
+typedef enum D2D1_COLOR_SPACE
+{
+ D2D1_COLOR_SPACE_CUSTOM = 0,
+ D2D1_COLOR_SPACE_SRGB = 1,
+ D2D1_COLOR_SPACE_SCRGB = 2,
+ D2D1_COLOR_SPACE_FORCE_DWORD = 0xffffffff,
+} D2D1_COLOR_SPACE;
+
+typedef struct D2D1_PRINT_CONTROL_PROPERTIES
+{
+ D2D1_PRINT_FONT_SUBSET_MODE fontSubset;
+ FLOAT rasterDPI;
+ D2D1_COLOR_SPACE colorSpace;
+} D2D1_PRINT_CONTROL_PROPERTIES;
+
+[
+ object,
+ uuid(47dd575d-ac05-4cdd-8049-9b02cd16f44c),
+ local,
+]
+interface ID2D1Device : ID2D1Resource
+{
+ HRESULT CreateDeviceContext(
+ [in] D2D1_DEVICE_CONTEXT_OPTIONS options,
+ [out] ID2D1DeviceContext **context
+ );
+ HRESULT CreatePrintControl(
+ [in] IWICImagingFactory *wic_factory,
+ [in] IPrintDocumentPackageTarget *document_target,
+ [in] const D2D1_PRINT_CONTROL_PROPERTIES *desc,
+ [out] ID2D1PrintControl **print_control
+ );
+ void SetMaximumTextureMemory(
+ [in] UINT64 max_texture_memory
+ );
+ UINT64 GetMaximumTextureMemory();
+ HRESULT ClearResources(
+ [in, defaultvalue(0)] UINT msec_since_use
+ );
+}
+
[
object,
uuid(bb12d362-daee-4b9a-aa1d-14ba401cfa1f),
--
2.17.0
More information about the wine-devel
mailing list