d2d1: Implement D2D1CreateDevice().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-06-17 20:44:29 +04:30 committed by Alexandre Julliard
parent 7d92b1abbd
commit f7f8006064
5 changed files with 70 additions and 1 deletions

View File

@ -4,7 +4,7 @@
@ stdcall D2D1IsMatrixInvertible(ptr)
@ stdcall D2D1InvertMatrix(ptr)
@ stub D2D1ConvertColorSpace
@ stub D2D1CreateDevice
@ stdcall D2D1CreateDevice(ptr ptr ptr)
@ stub D2D1CreateDeviceContext
@ stub D2D1SinCos
@ stub D2D1Tan

View File

@ -27,6 +27,7 @@
#include <math.h>
#define COBJMACROS
#include "d2d1_2.h"
#include "d3d11.h"
#ifdef D2D1_INIT_GUID
#include "initguid.h"
#endif

View File

@ -681,6 +681,38 @@ BOOL WINAPI D2D1InvertMatrix(D2D1_MATRIX_3X2_F *matrix)
return d2d_matrix_invert(matrix, &m);
}
HRESULT WINAPI D2D1CreateDevice(IDXGIDevice *dxgi_device,
const D2D1_CREATION_PROPERTIES *properties, ID2D1Device **device)
{
D2D1_CREATION_PROPERTIES default_properties = {0};
D2D1_FACTORY_OPTIONS factory_options;
ID3D11Device *d3d_device;
ID2D1Factory1 *factory;
HRESULT hr;
TRACE("dxgi_device %p, properties %p, device %p.\n", dxgi_device, properties, device);
if (!properties)
{
if (SUCCEEDED(IDXGIDevice_QueryInterface(dxgi_device, &IID_ID3D11Device, (void **)&d3d_device)))
{
if (!(ID3D11Device_GetCreationFlags(d3d_device) & D3D11_CREATE_DEVICE_SINGLETHREADED))
default_properties.threadingMode = D2D1_THREADING_MODE_MULTI_THREADED;
ID3D11Device_Release(d3d_device);
}
properties = &default_properties;
}
factory_options.debugLevel = properties->debugLevel;
if (FAILED(hr = D2D1CreateFactory(properties->threadingMode,
&IID_ID2D1Factory1, &factory_options, (void **)&factory)))
return hr;
hr = ID2D1Factory1_CreateDevice(factory, dxgi_device, device);
ID2D1Factory1_Release(factory);
return hr;
}
static BOOL get_config_key_dword(HKEY default_key, HKEY application_key, const char *name, DWORD *value)
{
DWORD type, data, size;

View File

@ -28,6 +28,9 @@
#include "wincodec.h"
#include "wine/heap.h"
static HRESULT (WINAPI *pD2D1CreateDevice)(IDXGIDevice *dxgi_device,
const D2D1_CREATION_PROPERTIES *properties, ID2D1Device **device);
static BOOL use_mt = TRUE;
static struct test_entry
@ -7911,6 +7914,7 @@ static void test_bezier_intersect(void)
static void test_create_device(void)
{
D2D1_CREATION_PROPERTIES properties = {0};
ID3D10Device1 *d3d_device;
IDXGIDevice *dxgi_device;
ID2D1Factory1 *factory;
@ -7943,6 +7947,19 @@ static void test_create_device(void)
ID2D1Factory_Release(factory2);
ID2D1Device_Release(device);
if (pD2D1CreateDevice)
{
hr = pD2D1CreateDevice(dxgi_device, NULL, &device);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
ID2D1Device_Release(device);
hr = pD2D1CreateDevice(dxgi_device, &properties, &device);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
ID2D1Device_Release(device);
}
else
win_skip("D2D1CreateDevice() is unavailable.\n");
IDXGIDevice_Release(dxgi_device);
ID3D10Device1_Release(d3d_device);
@ -9416,6 +9433,8 @@ START_TEST(d2d1)
unsigned int argc, i;
char **argv;
pD2D1CreateDevice = (void *)GetProcAddress(GetModuleHandleA("d2d1.dll"), "D2D1CreateDevice");
use_mt = !getenv("WINETEST_NO_MT_D3D");
argc = winetest_get_mainargs(&argv);

View File

@ -187,6 +187,20 @@ typedef enum D2D1_PROPERTY_TYPE
D2D1_PROPERTY_TYPE_FORCE_DWORD = 0xffffffff,
} D2D1_PROPERTY_TYPE;
typedef enum D2D1_THREADING_MODE
{
D2D1_THREADING_MODE_SINGLE_THREADED = D2D1_FACTORY_TYPE_SINGLE_THREADED,
D2D1_THREADING_MODE_MULTI_THREADED = D2D1_FACTORY_TYPE_MULTI_THREADED,
D2D1_THREADING_MODE_FORCE_DWORD = 0xffffffff,
} D2D1_THREADING_MODE;
typedef struct D2D1_CREATION_PROPERTIES
{
D2D1_THREADING_MODE threadingMode;
D2D1_DEBUG_LEVEL debugLevel;
D2D1_DEVICE_CONTEXT_OPTIONS options;
} D2D1_CREATION_PROPERTIES;
typedef struct D2D1_STROKE_STYLE_PROPERTIES1
{
D2D1_CAP_STYLE startCap;
@ -777,3 +791,6 @@ interface ID2D1Factory1 : ID2D1Factory
[out] ID2D1Properties **props
);
}
[local] HRESULT __stdcall D2D1CreateDevice(IDXGIDevice *dxgi_device,
const D2D1_CREATION_PROPERTIES *creation_properties, ID2D1Device **device);