Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d2d1/tests/Makefile.in | 2 +- dlls/d2d1/tests/d2d1.c | 344 +++++++++++++++++++++++++----------- 2 files changed, 239 insertions(+), 107 deletions(-)
diff --git a/dlls/d2d1/tests/Makefile.in b/dlls/d2d1/tests/Makefile.in index 91ede7888aa..5eeb815e07f 100644 --- a/dlls/d2d1/tests/Makefile.in +++ b/dlls/d2d1/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = d2d1.dll -IMPORTS = d2d1 d3d10_1 dwrite dxguid uuid user32 advapi32 ole32 gdi32 +IMPORTS = d2d1 d3d10_1 d3d11 dwrite dxguid uuid user32 advapi32 ole32 gdi32
C_SRCS = \ d2d1.c diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 798f98c335b..05b6429f491 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -21,6 +21,7 @@ #include <math.h> #include <float.h> #include "d2d1_1.h" +#include "d3d11.h" #include "wincrypt.h" #include "wine/test.h" #include "initguid.h" @@ -38,12 +39,14 @@ static BOOL use_mt = TRUE;
static struct test_entry { - void (*test)(void); + void (*test)(BOOL d3d11); + BOOL d3d11; } *mt_tests; size_t mt_tests_size, mt_test_count;
struct d2d1_test_context { + BOOL d3d11; IDXGIDevice *device; HWND window; IDXGISwapChain *swapchain; @@ -53,7 +56,11 @@ struct d2d1_test_context
struct resource_readback { - ID3D10Resource *resource; + union + { + ID3D10Resource *d3d10_resource; + ID3D11Resource *d3d11_resource; + } u; unsigned int pitch, width, height; void *data; }; @@ -108,14 +115,26 @@ struct expected_geometry_figure const struct geometry_segment *segments; };
-static void queue_test(void (*test)(void)) +static void queue_d3d1x_test(void (*test)(BOOL d3d11), BOOL d3d11) { if (mt_test_count >= mt_tests_size) { mt_tests_size = max(16, mt_tests_size * 2); mt_tests = heap_realloc(mt_tests, mt_tests_size * sizeof(*mt_tests)); } - mt_tests[mt_test_count++].test = test; + mt_tests[mt_test_count].test = test; + mt_tests[mt_test_count++].d3d11 = d3d11; +} + +static void queue_d3d10_test(void (*test)(BOOL d3d11)) +{ + queue_d3d1x_test(test, FALSE); +} + +static void queue_test(void (*test)(BOOL d3d11)) +{ + queue_d3d1x_test(test, FALSE); + queue_d3d1x_test(test, TRUE); }
static DWORD WINAPI thread_func(void *ctx) @@ -126,7 +145,7 @@ static DWORD WINAPI thread_func(void *ctx) { j = *i; if (InterlockedCompareExchange(i, j + 1, j) == j) - mt_tests[j].test(); + mt_tests[j].test(mt_tests[j].d3d11); }
return 0; @@ -143,7 +162,7 @@ static void run_queued_tests(void) { for (i = 0; i < mt_test_count; ++i) { - mt_tests[i].test(); + mt_tests[i].test(mt_tests[i].d3d11); }
return; @@ -311,7 +330,7 @@ static void cubic_to(ID2D1GeometrySink *sink, float x1, float y1, float x2, floa ID2D1GeometrySink_AddBezier(sink, &b); }
-static void get_surface_readback(struct d2d1_test_context *ctx, struct resource_readback *rb) +static void get_d3d10_surface_readback(struct d2d1_test_context *ctx, struct resource_readback *rb) { IDXGISurface *surface = ctx->surface; D3D10_TEXTURE2D_DESC texture_desc; @@ -338,27 +357,104 @@ static void get_surface_readback(struct d2d1_test_context *ctx, struct resource_ texture_desc.BindFlags = 0; texture_desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ; texture_desc.MiscFlags = 0; - hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, (ID3D10Texture2D **)&rb->resource); + hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, (ID3D10Texture2D **)&rb->u.d3d10_resource); ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
rb->width = texture_desc.Width; rb->height = texture_desc.Height;
- ID3D10Device_CopyResource(device, rb->resource, src_resource); + ID3D10Device_CopyResource(device, rb->u.d3d10_resource, src_resource); ID3D10Resource_Release(src_resource); ID3D10Device_Release(device);
- hr = ID3D10Texture2D_Map((ID3D10Texture2D *)rb->resource, 0, D3D10_MAP_READ, 0, &map_desc); + hr = ID3D10Texture2D_Map((ID3D10Texture2D *)rb->u.d3d10_resource, 0, D3D10_MAP_READ, 0, &map_desc); + ok(SUCCEEDED(hr), "Failed to map texture, hr %#x.\n", hr); + + rb->pitch = map_desc.RowPitch; + rb->data = map_desc.pData; +} + +static void get_d3d11_surface_readback(struct d2d1_test_context *ctx, struct resource_readback *rb) +{ + IDXGISurface *surface = ctx->surface; + D3D11_TEXTURE2D_DESC texture_desc; + D3D11_MAPPED_SUBRESOURCE map_desc; + DXGI_SURFACE_DESC surface_desc; + ID3D11Resource *src_resource; + ID3D11DeviceContext *context; + ID3D11Device *device; + HRESULT hr; + + hr = IDXGISurface_GetDevice(surface, &IID_ID3D11Device, (void **)&device); + ok(SUCCEEDED(hr), "Failed to get device, hr %#x.\n", hr); + hr = IDXGISurface_QueryInterface(surface, &IID_ID3D11Resource, (void **)&src_resource); + ok(SUCCEEDED(hr), "Failed to query resource interface, hr %#x.\n", hr); + + hr = IDXGISurface_GetDesc(surface, &surface_desc); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + texture_desc.Width = surface_desc.Width; + texture_desc.Height = surface_desc.Height; + texture_desc.MipLevels = 1; + texture_desc.ArraySize = 1; + texture_desc.Format = surface_desc.Format; + texture_desc.SampleDesc = surface_desc.SampleDesc; + texture_desc.Usage = D3D11_USAGE_STAGING; + texture_desc.BindFlags = 0; + texture_desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; + texture_desc.MiscFlags = 0; + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, (ID3D11Texture2D **)&rb->u.d3d11_resource); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + + rb->width = texture_desc.Width; + rb->height = texture_desc.Height; + + ID3D11Device_GetImmediateContext(device, &context); + ID3D11DeviceContext_CopyResource(context, rb->u.d3d11_resource, src_resource); + ID3D11Resource_Release(src_resource); + ID3D11Device_Release(device); + + hr = ID3D11DeviceContext_Map(context, (ID3D11Resource *)rb->u.d3d11_resource, 0, D3D11_MAP_READ, 0, &map_desc); ok(SUCCEEDED(hr), "Failed to map texture, hr %#x.\n", hr); + ID3D11DeviceContext_Release(context);
rb->pitch = map_desc.RowPitch; rb->data = map_desc.pData; }
+static void get_surface_readback(struct d2d1_test_context *ctx, struct resource_readback *rb) +{ + if (ctx->d3d11) get_d3d11_surface_readback(ctx, rb); + else get_d3d10_surface_readback(ctx, rb); +} + +static void release_d3d10_resource_readback(struct d2d1_test_context *ctx, struct resource_readback *rb) +{ + ID3D10Texture2D_Unmap((ID3D10Texture2D *)rb->u.d3d10_resource, 0); + ID3D10Resource_Release(rb->u.d3d10_resource); +} + +static void release_d3d11_resource_readback(struct d2d1_test_context *ctx, struct resource_readback *rb) +{ + IDXGISurface *surface = ctx->surface; + ID3D11DeviceContext *context; + ID3D11Device *device; + HRESULT hr; + + hr = IDXGISurface_GetDevice(surface, &IID_ID3D11Device, (void **)&device); + ok(SUCCEEDED(hr), "Failed to get device, hr %#x.\n", hr); + + ID3D11Device_GetImmediateContext(device, &context); + ID3D11Device_Release(device); + + ID3D11DeviceContext_Unmap(context, rb->u.d3d11_resource, 0); + ID3D11Resource_Release(rb->u.d3d11_resource); + ID3D11DeviceContext_Release(context); +} + static void release_resource_readback(struct d2d1_test_context *ctx, struct resource_readback *rb) { - ID3D10Texture2D_Unmap((ID3D10Texture2D *)rb->resource, 0); - ID3D10Resource_Release(rb->resource); + if (ctx->d3d11) release_d3d11_resource_readback(ctx, rb); + else release_d3d10_resource_readback(ctx, rb); }
static DWORD get_readback_colour(struct resource_readback *rb, unsigned int x, unsigned int y) @@ -711,19 +807,47 @@ static ID3D10Device1 *create_d3d10_device(void) return NULL; }
-static IDXGIDevice *create_device(void) +static ID3D11Device *create_d3d11_device(void) +{ + ID3D11Device *device; + DWORD level = D3D_FEATURE_LEVEL_11_0; + + if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, + D3D10_CREATE_DEVICE_BGRA_SUPPORT, &level, 1, D3D11_SDK_VERSION, &device, NULL, NULL))) + return device; + if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_WARP, NULL, + D3D10_CREATE_DEVICE_BGRA_SUPPORT, &level, 1, D3D11_SDK_VERSION, &device, NULL, NULL))) + return device; + if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_REFERENCE, NULL, + D3D10_CREATE_DEVICE_BGRA_SUPPORT, &level, 1, D3D11_SDK_VERSION, &device, NULL, NULL))) + return device; + + return NULL; +} + +static IDXGIDevice *create_device(BOOL d3d11) { ID3D10Device1 *d3d10_device; + ID3D11Device *d3d11_device; IDXGIDevice *device; HRESULT hr;
- if (!(d3d10_device = create_d3d10_device())) - return NULL; + if (d3d11) + { + if (!(d3d11_device = create_d3d11_device())) + return NULL; + hr = ID3D11Device_QueryInterface(d3d11_device, &IID_IDXGIDevice, (void **)&device); + ID3D11Device_Release(d3d11_device); + } + else + { + if (!(d3d10_device = create_d3d10_device())) + return NULL; + hr = ID3D10Device1_QueryInterface(d3d10_device, &IID_IDXGIDevice, (void **)&device); + ID3D10Device1_Release(d3d10_device); + }
- hr = ID3D10Device1_QueryInterface(d3d10_device, &IID_IDXGIDevice, (void **)&device); ok(SUCCEEDED(hr), "Failed to get DXGI device, hr %#x.\n", hr); - ID3D10Device1_Release(d3d10_device); - if (FAILED(hr)) return NULL;
@@ -791,7 +915,7 @@ static IDXGISwapChain *create_d3d10_swapchain(ID3D10Device1 *device, HWND window return swapchain; }
-static ID2D1RenderTarget *create_render_target_desc(IDXGISurface *surface, const D2D1_RENDER_TARGET_PROPERTIES *desc) +static ID2D1RenderTarget *create_render_target_desc(IDXGISurface *surface, const D2D1_RENDER_TARGET_PROPERTIES *desc, BOOL d3d11) { ID2D1RenderTarget *render_target; ID2D1Factory *factory; @@ -800,14 +924,14 @@ static ID2D1RenderTarget *create_render_target_desc(IDXGISurface *surface, const hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, NULL, (void **)&factory); ok(SUCCEEDED(hr), "Failed to create factory, hr %#x.\n", hr); hr = ID2D1Factory_CreateDxgiSurfaceRenderTarget(factory, surface, desc, &render_target); - ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr); + todo_wine_if(d3d11) ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr); ID2D1Factory_Release(factory);
if (FAILED(hr)) return NULL; return render_target; }
-static ID2D1RenderTarget *create_render_target(IDXGISurface *surface) +static ID2D1RenderTarget *create_render_target(IDXGISurface *surface, BOOL d3d11) { D2D1_RENDER_TARGET_PROPERTIES desc;
@@ -819,7 +943,7 @@ static ID2D1RenderTarget *create_render_target(IDXGISurface *surface) desc.usage = D2D1_RENDER_TARGET_USAGE_NONE; desc.minLevel = D2D1_FEATURE_LEVEL_DEFAULT;
- return create_render_target_desc(surface, &desc); + return create_render_target_desc(surface, &desc, d3d11); }
#define release_test_context(ctx) release_test_context_(__LINE__, ctx) @@ -842,14 +966,15 @@ static void release_test_context_(unsigned int line, struct d2d1_test_context *c IDXGIDevice_Release(ctx->device); }
-#define init_test_context(ctx) init_test_context_(__LINE__, ctx) -static BOOL init_test_context_(unsigned int line, struct d2d1_test_context *ctx) +#define init_test_context(ctx, d3d11) init_test_context_(__LINE__, ctx, d3d11) +static BOOL init_test_context_(unsigned int line, struct d2d1_test_context *ctx, BOOL d3d11) { HRESULT hr;
memset(ctx, 0, sizeof(*ctx));
- if (!(ctx->device = create_device())) + ctx->d3d11 = d3d11; + if (!(ctx->device = create_device(d3d11))) { skip("Failed to create device, skipping tests.\n"); return FALSE; @@ -879,7 +1004,14 @@ static BOOL init_test_context_(unsigned int line, struct d2d1_test_context *ctx) return FALSE; }
- ctx->rt = create_render_target(ctx->surface); + ctx->rt = create_render_target(ctx->surface, d3d11); + if (!ctx->rt && d3d11) + { + todo_wine win_skip_(__FILE__, line)("Skipping D3D11 tests.\n"); + release_test_context(ctx); + return FALSE; + } + ok(!!ctx->rt, "Failed to create render target.\n"); if (!ctx->rt) { @@ -1196,7 +1328,7 @@ static void geometry_sink_check_(unsigned int line, const struct geometry_sink * } }
-static void test_clip(void) +static void test_clip(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_MATRIX_3X2_F matrix; @@ -1216,7 +1348,7 @@ static void test_clip(void) 0.0f, 0.0f, }}};
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -1390,7 +1522,7 @@ static void test_clip(void) release_test_context(&ctx); }
-static void test_state_block(void) +static void test_state_block(BOOL d3d11) { struct d2d1_test_context ctx; IDWriteRenderingParams *text_rendering_params1, *text_rendering_params2; @@ -1421,7 +1553,7 @@ static void test_state_block(void) 11.0f, 12.0f, }}};
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -1651,7 +1783,7 @@ static void test_state_block(void) release_test_context(&ctx); }
-static void test_color_brush(void) +static void test_color_brush(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_MATRIX_3X2_F matrix, tmp_matrix; @@ -1664,7 +1796,7 @@ static void test_color_brush(void) HRESULT hr; BOOL match;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -1738,7 +1870,7 @@ static void test_color_brush(void) release_test_context(&ctx); }
-static void test_bitmap_brush(void) +static void test_bitmap_brush(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode; @@ -1790,7 +1922,7 @@ static void test_bitmap_brush(void) 0xffffffff, 0xff000000, 0xff000000, 0xff000000, };
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -2024,7 +2156,7 @@ static void test_bitmap_brush(void) release_test_context(&ctx); }
-static void test_linear_brush(void) +static void test_linear_brush(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES gradient_properties; @@ -2081,7 +2213,7 @@ static void test_linear_brush(void) {520, 390, 0xff90ae40}, };
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -2217,7 +2349,7 @@ static void test_linear_brush(void) release_test_context(&ctx); }
-static void test_radial_brush(void) +static void test_radial_brush(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES gradient_properties; @@ -2274,7 +2406,7 @@ static void test_radial_brush(void) {520, 390, 0xff4059e6}, };
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -2533,7 +2665,7 @@ static void fill_geometry_sink_bezier(ID2D1GeometrySink *sink, unsigned int holl ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED); }
-static void test_path_geometry(void) +static void test_path_geometry(BOOL d3d11) { struct d2d1_test_context ctx; ID2D1TransformedGeometry *transformed_geometry; @@ -2866,7 +2998,7 @@ static void test_path_geometry(void) {D2D1_FIGURE_BEGIN_HOLLOW, D2D1_FIGURE_END_OPEN, { 40.0f, 20.0f}, 2, &expected_segments[172]}, };
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -3593,7 +3725,7 @@ static void test_path_geometry(void) release_test_context(&ctx); }
-static void test_rectangle_geometry(void) +static void test_rectangle_geometry(BOOL d3d11) { ID2D1TransformedGeometry *transformed_geometry; ID2D1RectangleGeometry *geometry; @@ -3874,7 +4006,7 @@ static void test_rectangle_geometry(void) ID2D1Factory_Release(factory); }
-static void test_rounded_rectangle_geometry(void) +static void test_rounded_rectangle_geometry(BOOL d3d11) { ID2D1RoundedRectangleGeometry *geometry; D2D1_ROUNDED_RECT rect, rect2; @@ -3920,7 +4052,7 @@ static void test_rounded_rectangle_geometry(void) ID2D1Factory_Release(factory); }
-static void test_bitmap_formats(void) +static void test_bitmap_formats(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_BITMAP_PROPERTIES bitmap_desc; @@ -3953,7 +4085,7 @@ static void test_bitmap_formats(void) {DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, 0x8a}, };
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -3985,7 +4117,7 @@ static void test_bitmap_formats(void) release_test_context(&ctx); }
-static void test_alpha_mode(void) +static void test_alpha_mode(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_RENDER_TARGET_PROPERTIES rt_desc; @@ -4009,7 +4141,7 @@ static void test_alpha_mode(void) 0x7f7f7f7f, 0x7f000000, 0x7f000000, 0x7f000000, };
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -4106,7 +4238,7 @@ static void test_alpha_mode(void) rt_desc.dpiY = 0.0f; rt_desc.usage = D2D1_RENDER_TARGET_USAGE_NONE; rt_desc.minLevel = D2D1_FEATURE_LEVEL_DEFAULT; - rt = create_render_target_desc(ctx.surface, &rt_desc); + rt = create_render_target_desc(ctx.surface, &rt_desc, d3d11); ok(!!rt, "Failed to create render target.\n");
ID2D1RenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_ALIASED); @@ -4201,7 +4333,7 @@ static void test_alpha_mode(void) release_test_context(&ctx); }
-static void test_shared_bitmap(void) +static void test_shared_bitmap(BOOL d3d11) { struct d2d1_test_context ctx; IDXGISwapChain *swapchain2; @@ -4222,7 +4354,7 @@ static void test_shared_bitmap(void) HWND window2; HRESULT hr;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
window2 = create_window(); @@ -4287,7 +4419,7 @@ static void test_shared_bitmap(void) /* DXGI surface render targets with different devices but the same factory. */ IDXGISurface_Release(surface2); IDXGISwapChain_Release(swapchain2); - device2 = create_device(); + device2 = create_device(d3d11); ok(!!device2, "Failed to create device.\n"); swapchain2 = create_swapchain(device2, window2, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain2, 0, &IID_IDXGISurface, (void **)&surface2); @@ -4448,7 +4580,7 @@ static void test_shared_bitmap(void) CoUninitialize(); }
-static void test_bitmap_updates(void) +static void test_bitmap_updates(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_BITMAP_PROPERTIES bitmap_desc; @@ -4469,7 +4601,7 @@ static void test_bitmap_updates(void) 0xffffffff, 0xff000000, 0xff000000, 0xff000000, };
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -4538,7 +4670,7 @@ static void test_bitmap_updates(void) release_test_context(&ctx); }
-static void test_opacity_brush(void) +static void test_opacity_brush(BOOL d3d11) { struct d2d1_test_context ctx; ID2D1BitmapBrush *bitmap_brush, *opacity_brush; @@ -4564,7 +4696,7 @@ static void test_opacity_brush(void) 0xffffffff, 0x40000000, 0x40000000, 0xff000000, };
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -4705,7 +4837,7 @@ static void test_opacity_brush(void) release_test_context(&ctx); }
-static void test_create_target(void) +static void test_create_target(BOOL d3d11) { struct d2d1_test_context ctx; ID2D1Factory *factory; @@ -4728,7 +4860,7 @@ static void test_create_target(void) }; unsigned int i;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
@@ -4784,7 +4916,7 @@ static void test_create_target(void) release_test_context(&ctx); }
-static void test_draw_text_layout(void) +static void test_draw_text_layout(BOOL d3d11) { struct d2d1_test_context ctx; static const struct @@ -4833,7 +4965,7 @@ static void test_draw_text_layout(void) D2D1_RECT_F rect; unsigned int i;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
@@ -4962,7 +5094,7 @@ static void create_target_dibsection(HDC hdc, UINT32 width, UINT32 height) DeleteObject(SelectObject(hdc, hbm)); }
-static void test_dc_target(void) +static void test_dc_target(BOOL d3d11) { struct d2d1_test_context ctx; static const D2D1_PIXEL_FORMAT invalid_formats[] = @@ -4992,7 +5124,7 @@ static void test_dc_target(void) HRESULT hr; RECT rect;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return; release_test_context(&ctx);
@@ -5190,7 +5322,7 @@ todo_wine ID2D1Factory_Release(factory); }
-static void test_hwnd_target(void) +static void test_hwnd_target(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_HWND_RENDER_TARGET_PROPERTIES hwnd_rt_desc; @@ -5202,7 +5334,7 @@ static void test_hwnd_target(void) D2D1_SIZE_U size; HRESULT hr;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return; release_test_context(&ctx);
@@ -5350,7 +5482,7 @@ static void test_compatible_target_size_(unsigned int line, ID2D1RenderTarget *r ID2D1BitmapRenderTarget_Release(bitmap_rt); }
-static void test_bitmap_target(void) +static void test_bitmap_target(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_HWND_RENDER_TARGET_PROPERTIES hwnd_rt_desc; @@ -5369,7 +5501,7 @@ static void test_bitmap_target(void) ULONG refcount; HRESULT hr;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return; release_test_context(&ctx);
@@ -5536,7 +5668,7 @@ static void test_bitmap_target(void) ID2D1Factory_Release(factory); }
-static void test_desktop_dpi(void) +static void test_desktop_dpi(BOOL d3d11) { ID2D1Factory *factory; float dpi_x, dpi_y; @@ -5552,7 +5684,7 @@ static void test_desktop_dpi(void) ID2D1Factory_Release(factory); }
-static void test_stroke_style(void) +static void test_stroke_style(BOOL d3d11) { static const struct { @@ -5696,7 +5828,7 @@ static void test_stroke_style(void) ID2D1Factory_Release(factory); }
-static void test_gradient(void) +static void test_gradient(BOOL d3d11) { struct d2d1_test_context ctx; ID2D1GradientStopCollection *gradient; @@ -5707,7 +5839,7 @@ static void test_gradient(void) UINT32 count; HRESULT hr;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -5741,7 +5873,7 @@ static void test_gradient(void) release_test_context(&ctx); }
-static void test_draw_geometry(void) +static void test_draw_geometry(BOOL d3d11) { struct d2d1_test_context ctx; ID2D1TransformedGeometry *transformed_geometry[4]; @@ -5761,7 +5893,7 @@ static void test_draw_geometry(void) HRESULT hr; BOOL match;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -6654,7 +6786,7 @@ static void test_draw_geometry(void) release_test_context(&ctx); }
-static void test_fill_geometry(void) +static void test_fill_geometry(BOOL d3d11) { struct d2d1_test_context ctx; ID2D1TransformedGeometry *transformed_geometry[4]; @@ -6673,7 +6805,7 @@ static void test_fill_geometry(void) HRESULT hr; BOOL match;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -7453,7 +7585,7 @@ static void test_fill_geometry(void) release_test_context(&ctx); }
-static void test_gdi_interop(void) +static void test_gdi_interop(BOOL d3d11) { struct d2d1_test_context ctx; ID2D1GdiInteropRenderTarget *interop; @@ -7469,7 +7601,7 @@ static void test_gdi_interop(void) RECT rect; HDC dc;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, NULL, (void **)&factory); @@ -7584,7 +7716,7 @@ todo_wine release_test_context(&ctx); }
-static void test_layer(void) +static void test_layer(BOOL d3d11) { struct d2d1_test_context ctx; ID2D1Factory *factory, *layer_factory; @@ -7593,7 +7725,7 @@ static void test_layer(void) D2D1_SIZE_F size; HRESULT hr;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -7625,7 +7757,7 @@ static void test_layer(void) release_test_context(&ctx); }
-static void test_bezier_intersect(void) +static void test_bezier_intersect(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_POINT_2F point = {0.0f, 0.0f}; @@ -7638,7 +7770,7 @@ static void test_bezier_intersect(void) HRESULT hr; BOOL match;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -7760,7 +7892,7 @@ static void test_bezier_intersect(void) release_test_context(&ctx); }
-static void test_create_device(void) +static void test_create_device(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_CREATION_PROPERTIES properties = {0}; @@ -7771,7 +7903,7 @@ static void test_create_device(void) ULONG refcount; HRESULT hr;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory))) @@ -7999,7 +8131,7 @@ static IDXGISurface *create_surface(IDXGIDevice *dxgi_device, DXGI_FORMAT format return surface; }
-static void test_bitmap_surface(void) +static void test_bitmap_surface(BOOL d3d11) { struct d2d1_test_context ctx; static const struct bitmap_format_test @@ -8047,7 +8179,7 @@ static void test_bitmap_surface(void) IWICBitmap *wic_bitmap; IWICImagingFactory *wic_factory;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory))) @@ -8246,7 +8378,7 @@ static void test_bitmap_surface(void) release_test_context(&ctx); }
-static void test_device_context(void) +static void test_device_context(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_HWND_RENDER_TARGET_PROPERTIES hwnd_rt_desc; @@ -8269,7 +8401,7 @@ static void test_device_context(void) IWICBitmap *wic_bitmap; IWICImagingFactory *wic_factory;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory))) @@ -8439,7 +8571,7 @@ todo_wine release_test_context(&ctx); }
-static void test_invert_matrix(void) +static void test_invert_matrix(BOOL d3d11) { static const struct { @@ -8522,7 +8654,7 @@ static void test_invert_matrix(void) } }
-static void test_skew_matrix(void) +static void test_skew_matrix(BOOL d3d11) { static const struct { @@ -8560,7 +8692,7 @@ static void test_skew_matrix(void) } }
-static ID2D1DeviceContext *create_device_context(ID2D1Factory1 *factory, IDXGIDevice *dxgi_device) +static ID2D1DeviceContext *create_device_context(ID2D1Factory1 *factory, IDXGIDevice *dxgi_device, BOOL d3d11) { ID2D1DeviceContext *device_context; ID2D1Device *device; @@ -8576,7 +8708,7 @@ static ID2D1DeviceContext *create_device_context(ID2D1Factory1 *factory, IDXGIDe return device_context; }
-static void test_command_list(void) +static void test_command_list(BOOL d3d11) { struct d2d1_test_context ctx; static const DWORD bitmap_data[] = @@ -8610,7 +8742,7 @@ static void test_command_list(void) ULONG refcount; HRESULT hr;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory))) @@ -8620,7 +8752,7 @@ static void test_command_list(void) return; }
- device_context = create_device_context(factory, ctx.device); + device_context = create_device_context(factory, ctx.device, d3d11); ok(device_context != NULL, "Failed to create device context.\n");
hr = ID2D1DeviceContext_CreateCommandList(device_context, &command_list); @@ -8806,7 +8938,7 @@ todo_wine ID2D1CommandList_Release(command_list);
/* List created with different context. */ - device_context2 = create_device_context(factory, ctx.device); + device_context2 = create_device_context(factory, ctx.device, d3d11); ok(device_context2 != NULL, "Failed to create device context.\n");
hr = ID2D1DeviceContext_CreateCommandList(device_context, &command_list); @@ -8825,7 +8957,7 @@ todo_wine release_test_context(&ctx); }
-static void test_max_bitmap_size(void) +static void test_max_bitmap_size(BOOL d3d11) { D2D1_RENDER_TARGET_PROPERTIES desc; D2D1_BITMAP_PROPERTIES bitmap_desc; @@ -8943,7 +9075,7 @@ static void test_max_bitmap_size(void) ID2D1Factory_Release(factory); }
-static void test_dpi(void) +static void test_dpi(BOOL d3d11) { struct d2d1_test_context ctx; D2D1_BITMAP_PROPERTIES1 bitmap_desc; @@ -8974,7 +9106,7 @@ static void test_dpi(void) static const float dc_dpi_x = 120.0f, dc_dpi_y = 144.0f; unsigned int i;
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory))) @@ -8985,7 +9117,7 @@ static void test_dpi(void) }
- device_context = create_device_context(factory, ctx.device); + device_context = create_device_context(factory, ctx.device, d3d11); ok(!!device_context, "Failed to create device context.\n");
ID2D1DeviceContext_GetDpi(device_context, &dpi_x, &dpi_y); @@ -9155,7 +9287,7 @@ static void test_dpi(void) release_test_context(&ctx); }
-static void test_wic_bitmap_format(void) +static void test_wic_bitmap_format(BOOL d3d11) { struct d2d1_test_context ctx; IWICImagingFactory *wic_factory; @@ -9178,7 +9310,7 @@ static void test_wic_bitmap_format(void) {&GUID_WICPixelFormat32bppBGR, {DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE}}, };
- if (!init_test_context(&ctx)) + if (!init_test_context(&ctx, d3d11)) return;
ID2D1RenderTarget_AddRef(rt = ctx.rt); @@ -9213,7 +9345,7 @@ static void test_wic_bitmap_format(void) release_test_context(&ctx); }
-static void test_math(void) +static void test_math(BOOL d3d11) { float s, c, t, l; unsigned int i; @@ -9322,8 +9454,8 @@ START_TEST(d2d1) queue_test(test_linear_brush); queue_test(test_radial_brush); queue_test(test_path_geometry); - queue_test(test_rectangle_geometry); - queue_test(test_rounded_rectangle_geometry); + queue_d3d10_test(test_rectangle_geometry); + queue_d3d10_test(test_rounded_rectangle_geometry); queue_test(test_bitmap_formats); queue_test(test_alpha_mode); queue_test(test_shared_bitmap); @@ -9334,8 +9466,8 @@ START_TEST(d2d1) queue_test(test_dc_target); queue_test(test_hwnd_target); queue_test(test_bitmap_target); - queue_test(test_desktop_dpi); - queue_test(test_stroke_style); + queue_d3d10_test(test_desktop_dpi); + queue_d3d10_test(test_stroke_style); queue_test(test_gradient); queue_test(test_draw_geometry); queue_test(test_fill_geometry); @@ -9345,13 +9477,13 @@ START_TEST(d2d1) queue_test(test_create_device); queue_test(test_bitmap_surface); queue_test(test_device_context); - queue_test(test_invert_matrix); - queue_test(test_skew_matrix); + queue_d3d10_test(test_invert_matrix); + queue_d3d10_test(test_skew_matrix); queue_test(test_command_list); - queue_test(test_max_bitmap_size); + queue_d3d10_test(test_max_bitmap_size); queue_test(test_dpi); queue_test(test_wic_bitmap_format); - queue_test(test_math); + queue_d3d10_test(test_math);
run_queued_tests(); }