[PATCH v2 02/12] d2d1/tests: Introduce d2d1_test_context structure.
Rémi Bernon
rbernon at codeweavers.com
Tue Jan 12 05:34:42 CST 2021
And use it to factor device creation.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/d2d1/tests/d2d1.c | 374 ++++++++++++++++++-----------------------
1 file changed, 167 insertions(+), 207 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 3f9159f9033..617d246485b 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -42,6 +42,11 @@ static struct test_entry
} *mt_tests;
size_t mt_tests_size, mt_test_count;
+struct d2d1_test_context
+{
+ ID3D10Device1 *device;
+};
+
struct resource_readback
{
ID3D10Resource *resource;
@@ -779,6 +784,26 @@ static ID2D1RenderTarget *create_render_target(IDXGISurface *surface)
return create_render_target_desc(surface, &desc);
}
+#define release_test_context(ctx) release_test_context_(__LINE__, ctx)
+static void release_test_context_(unsigned int line, struct d2d1_test_context *ctx)
+{
+ ID3D10Device1_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)
+{
+ memset(ctx, 0, sizeof(*ctx));
+
+ if (!(ctx->device = create_device()))
+ {
+ skip("Failed to create device, skipping tests.\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
#define check_bitmap_surface(b, s, o) check_bitmap_surface_(__LINE__, b, s, o)
static void check_bitmap_surface_(unsigned int line, ID2D1Bitmap *bitmap, BOOL has_surface, DWORD expected_options)
{
@@ -1087,11 +1112,11 @@ static void geometry_sink_check_(unsigned int line, const struct geometry_sink *
static void test_clip(void)
{
+ struct d2d1_test_context ctx;
IDXGISwapChain *swapchain;
D2D1_MATRIX_3X2_F matrix;
D2D1_SIZE_U pixel_size;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
D2D1_POINT_2F point;
D2D1_COLOR_F color;
@@ -1108,13 +1133,11 @@ static void test_clip(void)
0.0f, 0.0f,
}}};
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -1288,12 +1311,13 @@ static void test_clip(void)
ID2D1RenderTarget_Release(rt);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_state_block(void)
{
+ struct d2d1_test_context ctx;
IDWriteRenderingParams *text_rendering_params1, *text_rendering_params2;
D2D1_DRAWING_STATE_DESCRIPTION drawing_state;
ID2D1DrawingStateBlock *state_block;
@@ -1301,7 +1325,6 @@ static void test_state_block(void)
IDXGISwapChain *swapchain;
ID2D1Factory1 *factory1;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Factory *factory;
ULONG refcount;
@@ -1326,13 +1349,11 @@ static void test_state_block(void)
11.0f, 12.0f,
}}};
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -1562,19 +1583,19 @@ static void test_state_block(void)
ID2D1RenderTarget_Release(rt);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_color_brush(void)
{
+ struct d2d1_test_context ctx;
D2D1_MATRIX_3X2_F matrix, tmp_matrix;
D2D1_BRUSH_PROPERTIES brush_desc;
D2D1_COLOR_F color, tmp_color;
ID2D1SolidColorBrush *brush;
IDXGISwapChain *swapchain;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
D2D1_RECT_F rect;
float opacity;
@@ -1582,13 +1603,11 @@ static void test_color_brush(void)
HRESULT hr;
BOOL match;
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -1662,12 +1681,13 @@ static void test_color_brush(void)
ID2D1RenderTarget_Release(rt);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_bitmap_brush(void)
{
+ struct d2d1_test_context ctx;
D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode;
ID2D1TransformedGeometry *transformed_geometry;
ID2D1RectangleGeometry *rectangle_geometry;
@@ -1680,7 +1700,6 @@ static void test_bitmap_brush(void)
ID2D1BitmapBrush1 *brush1;
ID2D1BitmapBrush *brush;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Factory *factory;
D2D1_COLOR_F color;
@@ -1721,13 +1740,11 @@ static void test_bitmap_brush(void)
0xffffffff, 0xff000000, 0xff000000, 0xff000000,
};
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -1961,12 +1978,13 @@ static void test_bitmap_brush(void)
ID2D1RenderTarget_Release(rt);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_linear_brush(void)
{
+ struct d2d1_test_context ctx;
D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES gradient_properties;
ID2D1GradientStopCollection *gradient, *tmp_gradient;
ID2D1TransformedGeometry *transformed_geometry;
@@ -1976,7 +1994,6 @@ static void test_linear_brush(void)
struct resource_readback rb;
IDXGISwapChain *swapchain;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Factory *factory;
D2D1_COLOR_F colour;
@@ -2025,13 +2042,11 @@ static void test_linear_brush(void)
{520, 390, 0xff90ae40},
};
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -2167,12 +2182,13 @@ static void test_linear_brush(void)
ID2D1RenderTarget_Release(rt);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_radial_brush(void)
{
+ struct d2d1_test_context ctx;
D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES gradient_properties;
ID2D1GradientStopCollection *gradient, *tmp_gradient;
ID2D1TransformedGeometry *transformed_geometry;
@@ -2182,7 +2198,6 @@ static void test_radial_brush(void)
struct resource_readback rb;
IDXGISwapChain *swapchain;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Factory *factory;
D2D1_COLOR_F colour;
@@ -2231,13 +2246,11 @@ static void test_radial_brush(void)
{520, 390, 0xff4059e6},
};
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -2381,7 +2394,7 @@ static void test_radial_brush(void)
ID2D1RenderTarget_Release(rt);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
@@ -2502,6 +2515,7 @@ static void fill_geometry_sink_bezier(ID2D1GeometrySink *sink, unsigned int holl
static void test_path_geometry(void)
{
+ struct d2d1_test_context ctx;
ID2D1TransformedGeometry *transformed_geometry;
D2D1_MATRIX_3X2_F matrix, tmp_matrix;
ID2D1GeometrySink *sink, *tmp_sink;
@@ -2512,7 +2526,6 @@ static void test_path_geometry(void)
ID2D1Geometry *tmp_geometry;
IDXGISwapChain *swapchain;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Factory *factory;
BOOL match, contains;
@@ -2837,13 +2850,11 @@ static void test_path_geometry(void)
{D2D1_FIGURE_BEGIN_HOLLOW, D2D1_FIGURE_END_OPEN, { 40.0f, 20.0f}, 2, &expected_segments[172]},
};
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -3571,7 +3582,7 @@ static void test_path_geometry(void)
ok(!refcount, "Factory has %u references left.\n", refcount);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
@@ -3904,11 +3915,11 @@ static void test_rounded_rectangle_geometry(void)
static void test_bitmap_formats(void)
{
+ struct d2d1_test_context ctx;
D2D1_BITMAP_PROPERTIES bitmap_desc;
IDXGISwapChain *swapchain;
D2D1_SIZE_U size = {4, 4};
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Bitmap *bitmap;
unsigned int i, j;
@@ -3938,13 +3949,11 @@ static void test_bitmap_formats(void)
{DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, 0x8a},
};
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -3976,19 +3985,19 @@ static void test_bitmap_formats(void)
ID2D1RenderTarget_Release(rt);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_alpha_mode(void)
{
+ struct d2d1_test_context ctx;
D2D1_RENDER_TARGET_PROPERTIES rt_desc;
D2D1_BITMAP_PROPERTIES bitmap_desc;
ID2D1SolidColorBrush *color_brush;
ID2D1BitmapBrush *bitmap_brush;
IDXGISwapChain *swapchain;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Bitmap *bitmap;
D2D1_COLOR_F color;
@@ -4007,13 +4016,11 @@ static void test_alpha_mode(void)
0x7f7f7f7f, 0x7f000000, 0x7f000000, 0x7f000000,
};
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -4205,12 +4212,13 @@ static void test_alpha_mode(void)
ID2D1RenderTarget_Release(rt);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_shared_bitmap(void)
{
+ struct d2d1_test_context ctx;
IDXGISwapChain *swapchain1, *swapchain2;
IWICBitmap *wic_bitmap1, *wic_bitmap2;
ID2D1GdiInteropRenderTarget *interop;
@@ -4219,7 +4227,7 @@ static void test_shared_bitmap(void)
ID2D1RenderTarget *rt1, *rt2, *rt3;
IDXGISurface *surface1, *surface2;
ID2D1Factory *factory1, *factory2;
- ID3D10Device1 *device1, *device2;
+ ID3D10Device1 *device2;
IWICImagingFactory *wic_factory;
ID2D1Bitmap *bitmap1, *bitmap2;
DXGI_SURFACE_DESC surface_desc;
@@ -4229,16 +4237,13 @@ static void test_shared_bitmap(void)
HWND window1, window2;
HRESULT hr;
- if (!(device1 = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
window1 = create_window();
window2 = create_window();
- swapchain1 = create_swapchain(device1, window1, TRUE);
- swapchain2 = create_swapchain(device1, window2, TRUE);
+ swapchain1 = create_swapchain(ctx.device, window1, TRUE);
+ swapchain2 = create_swapchain(ctx.device, window2, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain1, 0, &IID_IDXGISurface, (void **)&surface1);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
hr = IDXGISwapChain_GetBuffer(swapchain2, 0, &IID_IDXGISurface, (void **)&surface2);
@@ -4459,7 +4464,7 @@ static void test_shared_bitmap(void)
IDXGISwapChain_Release(swapchain2);
IDXGISwapChain_Release(swapchain1);
ID3D10Device1_Release(device2);
- ID3D10Device1_Release(device1);
+ release_test_context(&ctx);
DestroyWindow(window2);
DestroyWindow(window1);
CoUninitialize();
@@ -4467,10 +4472,10 @@ static void test_shared_bitmap(void)
static void test_bitmap_updates(void)
{
+ struct d2d1_test_context ctx;
D2D1_BITMAP_PROPERTIES bitmap_desc;
IDXGISwapChain *swapchain;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
D2D1_RECT_U dst_rect;
ID2D1Bitmap *bitmap;
@@ -4489,13 +4494,11 @@ static void test_bitmap_updates(void)
0xffffffff, 0xff000000, 0xff000000, 0xff000000,
};
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -4564,12 +4567,13 @@ static void test_bitmap_updates(void)
ID2D1RenderTarget_Release(rt);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_opacity_brush(void)
{
+ struct d2d1_test_context ctx;
ID2D1BitmapBrush *bitmap_brush, *opacity_brush;
D2D1_BITMAP_PROPERTIES bitmap_desc;
ID2D1RectangleGeometry *geometry;
@@ -4577,7 +4581,6 @@ static void test_opacity_brush(void)
IDXGISwapChain *swapchain;
D2D1_MATRIX_3X2_F matrix;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Factory *factory;
ID2D1Bitmap *bitmap;
@@ -4597,13 +4600,11 @@ static void test_opacity_brush(void)
0xffffffff, 0x40000000, 0x40000000, 0xff000000,
};
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -4745,16 +4746,16 @@ static void test_opacity_brush(void)
ok(!refcount, "Factory has %u references left.\n", refcount);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_create_target(void)
{
+ struct d2d1_test_context ctx;
IDXGISwapChain *swapchain;
ID2D1Factory *factory;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
HWND window;
HRESULT hr;
@@ -4775,13 +4776,11 @@ static void test_create_target(void)
};
unsigned int i;
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
@@ -4836,12 +4835,13 @@ static void test_create_target(void)
ID2D1Factory_Release(factory);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_draw_text_layout(void)
{
+ struct d2d1_test_context ctx;
static const struct
{
D2D1_TEXT_ANTIALIAS_MODE aa_mode;
@@ -4877,7 +4877,6 @@ static void test_draw_text_layout(void)
IDXGISwapChain *swapchain;
ID2D1Factory *factory, *factory2;
ID2D1RenderTarget *rt, *rt2;
- ID3D10Device1 *device;
IDXGISurface *surface;
HWND window;
HRESULT hr;
@@ -4892,13 +4891,11 @@ static void test_draw_text_layout(void)
D2D1_RECT_F rect;
unsigned int i;
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
@@ -5006,7 +5003,7 @@ todo_wine
ID2D1Factory_Release(factory2);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
@@ -5032,6 +5029,7 @@ static void create_target_dibsection(HDC hdc, UINT32 width, UINT32 height)
static void test_dc_target(void)
{
+ struct d2d1_test_context ctx;
static const D2D1_PIXEL_FORMAT invalid_formats[] =
{
{ DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED },
@@ -5047,7 +5045,6 @@ static void test_dc_target(void)
ID2D1SolidColorBrush *brush;
ID2D1RenderTarget *rt3;
ID2D1Factory *factory;
- ID3D10Device1 *device;
FLOAT dpi_x, dpi_y;
D2D1_COLOR_F color;
D2D1_SIZE_U sizeu;
@@ -5060,12 +5057,9 @@ static void test_dc_target(void)
HRESULT hr;
RECT rect;
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, NULL, (void **)&factory);
ok(SUCCEEDED(hr), "Failed to create factory, hr %#x.\n", hr);
@@ -5263,22 +5257,19 @@ todo_wine
static void test_hwnd_target(void)
{
+ struct d2d1_test_context ctx;
D2D1_HWND_RENDER_TARGET_PROPERTIES hwnd_rt_desc;
ID2D1GdiInteropRenderTarget *interop;
D2D1_RENDER_TARGET_PROPERTIES desc;
ID2D1HwndRenderTarget *rt, *rt2;
ID2D1RenderTarget *rt3;
ID2D1Factory *factory;
- ID3D10Device1 *device;
D2D1_SIZE_U size;
HRESULT hr;
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, NULL, (void **)&factory);
ok(SUCCEEDED(hr), "Failed to create factory, hr %#x.\n", hr);
@@ -5426,6 +5417,7 @@ static void test_compatible_target_size_(unsigned int line, ID2D1RenderTarget *r
static void test_bitmap_target(void)
{
+ struct d2d1_test_context ctx;
D2D1_HWND_RENDER_TARGET_PROPERTIES hwnd_rt_desc;
ID2D1GdiInteropRenderTarget *interop;
D2D1_SIZE_U pixel_size, pixel_size2;
@@ -5437,18 +5429,14 @@ static void test_bitmap_target(void)
D2D1_SIZE_F size, size2;
ID2D1RenderTarget *rt3;
ID2D1Factory *factory;
- ID3D10Device1 *device;
float dpi[2], dpi2[2];
D2D1_COLOR_F color;
ULONG refcount;
HRESULT hr;
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, NULL, (void **)&factory);
ok(SUCCEEDED(hr), "Failed to create factory, hr %#x.\n", hr);
@@ -5775,11 +5763,11 @@ static void test_stroke_style(void)
static void test_gradient(void)
{
+ struct d2d1_test_context ctx;
ID2D1GradientStopCollection *gradient;
D2D1_GRADIENT_STOP stops[3], stops2[3];
IDXGISwapChain *swapchain;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
D2D1_COLOR_F color;
unsigned int i;
@@ -5787,13 +5775,11 @@ static void test_gradient(void)
HWND window;
HRESULT hr;
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -5827,12 +5813,13 @@ static void test_gradient(void)
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_draw_geometry(void)
{
+ struct d2d1_test_context ctx;
ID2D1TransformedGeometry *transformed_geometry[4];
ID2D1RectangleGeometry *rect_geometry[2];
D2D1_POINT_2F point = {0.0f, 0.0f};
@@ -5843,7 +5830,6 @@ static void test_draw_geometry(void)
D2D1_MATRIX_3X2_F matrix;
ID2D1GeometrySink *sink;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Factory *factory;
D2D1_POINT_2F p0, p1;
@@ -5855,13 +5841,11 @@ static void test_draw_geometry(void)
HRESULT hr;
BOOL match;
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -6755,12 +6739,13 @@ static void test_draw_geometry(void)
ok(!refcount, "Factory has %u references left.\n", refcount);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_fill_geometry(void)
{
+ struct d2d1_test_context ctx;
ID2D1TransformedGeometry *transformed_geometry[4];
ID2D1RectangleGeometry *rect_geometry[2];
D2D1_POINT_2F point = {0.0f, 0.0f};
@@ -6771,7 +6756,6 @@ static void test_fill_geometry(void)
D2D1_MATRIX_3X2_F matrix;
ID2D1GeometrySink *sink;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Factory *factory;
D2D1_ELLIPSE ellipse;
@@ -6782,13 +6766,11 @@ static void test_fill_geometry(void)
HRESULT hr;
BOOL match;
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -7569,12 +7551,13 @@ static void test_fill_geometry(void)
ok(!refcount, "Factory has %u references left.\n", refcount);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_gdi_interop(void)
{
+ struct d2d1_test_context ctx;
ID2D1GdiInteropRenderTarget *interop;
D2D1_RENDER_TARGET_PROPERTIES desc;
IWICImagingFactory *wic_factory;
@@ -7582,18 +7565,14 @@ static void test_gdi_interop(void)
IWICBitmap *wic_bitmap;
ID2D1RenderTarget *rt;
ID2D1Factory *factory;
- ID3D10Device1 *device;
D2D1_COLOR_F color;
HRESULT hr;
BOOL match;
RECT rect;
HDC dc;
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, NULL, (void **)&factory);
ok(SUCCEEDED(hr), "Failed to create factory, hr %#x.\n", hr);
@@ -7704,14 +7683,15 @@ todo_wine
IWICBitmap_Release(wic_bitmap);
ID2D1Factory_Release(factory);
+ release_test_context(&ctx);
}
static void test_layer(void)
{
+ struct d2d1_test_context ctx;
ID2D1Factory *factory, *layer_factory;
IDXGISwapChain *swapchain;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Layer *layer;
D2D1_SIZE_F size;
@@ -7719,13 +7699,11 @@ static void test_layer(void)
HWND window;
HRESULT hr;
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -7758,19 +7736,19 @@ static void test_layer(void)
ok(!refcount, "Factory has %u references left.\n", refcount);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_bezier_intersect(void)
{
+ struct d2d1_test_context ctx;
D2D1_POINT_2F point = {0.0f, 0.0f};
ID2D1SolidColorBrush *brush;
ID2D1PathGeometry *geometry;
IDXGISwapChain *swapchain;
ID2D1GeometrySink *sink;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Factory *factory;
D2D1_COLOR_F color;
@@ -7779,13 +7757,11 @@ static void test_bezier_intersect(void)
HRESULT hr;
BOOL match;
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -7908,14 +7884,14 @@ static void test_bezier_intersect(void)
ok(!refcount, "Factory has %u references left.\n", refcount);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_create_device(void)
{
+ struct d2d1_test_context ctx;
D2D1_CREATION_PROPERTIES properties = {0};
- ID3D10Device1 *d3d_device;
IDXGIDevice *dxgi_device;
ID2D1Factory1 *factory;
ID2D1Factory *factory2;
@@ -7923,20 +7899,17 @@ static void test_create_device(void)
ULONG refcount;
HRESULT hr;
- if (!(d3d_device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory)))
{
win_skip("ID2D1Factory1 is not supported.\n");
- ID3D10Device1_Release(d3d_device);
+ release_test_context(&ctx);
return;
}
- hr = ID3D10Device1_QueryInterface(d3d_device, &IID_IDXGIDevice, (void **)&dxgi_device);
+ hr = ID3D10Device1_QueryInterface(ctx.device, &IID_IDXGIDevice, (void **)&dxgi_device);
ok(SUCCEEDED(hr), "Failed to get IDXGIDevice interface, hr %#x.\n", hr);
hr = ID2D1Factory1_CreateDevice(factory, dxgi_device, &device);
@@ -7961,7 +7934,7 @@ static void test_create_device(void)
win_skip("D2D1CreateDevice() is unavailable.\n");
IDXGIDevice_Release(dxgi_device);
- ID3D10Device1_Release(d3d_device);
+ release_test_context(&ctx);
refcount = ID2D1Factory1_Release(factory);
ok(!refcount, "Factory has %u references left.\n", refcount);
@@ -8157,6 +8130,7 @@ static IDXGISurface *create_surface(IDXGIDevice *dxgi_device, DXGI_FORMAT format
static void test_bitmap_surface(void)
{
+ struct d2d1_test_context ctx;
static const struct bitmap_format_test
{
D2D1_PIXEL_FORMAT original;
@@ -8188,7 +8162,6 @@ static void test_bitmap_surface(void)
ID2D1DeviceContext *device_context;
IDXGISurface *surface, *surface2;
D2D1_PIXEL_FORMAT pixel_format;
- ID3D10Device1 *d3d_device;
IDXGISwapChain *swapchain;
IDXGIDevice *dxgi_device;
ID2D1Factory1 *factory;
@@ -8205,22 +8178,19 @@ static void test_bitmap_surface(void)
IWICBitmap *wic_bitmap;
IWICImagingFactory *wic_factory;
- if (!(d3d_device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory)))
{
win_skip("ID2D1Factory1 is not supported.\n");
- ID3D10Device1_Release(d3d_device);
+ release_test_context(&ctx);
return;
}
/* DXGI target */
window = create_window();
- swapchain = create_swapchain(d3d_device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -8242,7 +8212,7 @@ static void test_bitmap_surface(void)
ID2D1RenderTarget_Release(rt);
/* Bitmap created from DXGI surface. */
- hr = ID3D10Device1_QueryInterface(d3d_device, &IID_IDXGIDevice, (void **)&dxgi_device);
+ hr = ID3D10Device1_QueryInterface(ctx.device, &IID_IDXGIDevice, (void **)&dxgi_device);
ok(SUCCEEDED(hr), "Failed to get IDXGIDevice interface, hr %#x.\n", hr);
hr = ID2D1Factory1_CreateDevice(factory, dxgi_device, &device);
@@ -8411,11 +8381,12 @@ static void test_bitmap_surface(void)
CoUninitialize();
ID2D1Factory1_Release(factory);
- ID3D10Device1_Release(d3d_device);
+ release_test_context(&ctx);
}
static void test_device_context(void)
{
+ struct d2d1_test_context ctx;
D2D1_HWND_RENDER_TARGET_PROPERTIES hwnd_rt_desc;
D2D1_RENDER_TARGET_PROPERTIES rt_desc;
ID2D1DeviceContext *device_context;
@@ -8423,7 +8394,6 @@ static void test_device_context(void)
ID2D1Device *device, *device2;
D2D1_BITMAP_OPTIONS options;
ID2D1DCRenderTarget *dc_rt;
- ID3D10Device1 *d3d_device;
IDXGISwapChain *swapchain;
IDXGIDevice *dxgi_device;
D2D1_UNIT_MODE unit_mode;
@@ -8439,20 +8409,17 @@ static void test_device_context(void)
IWICBitmap *wic_bitmap;
IWICImagingFactory *wic_factory;
- if (!(d3d_device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory)))
{
win_skip("ID2D1Factory1 is not supported.\n");
- ID3D10Device1_Release(d3d_device);
+ release_test_context(&ctx);
return;
}
- hr = ID3D10Device1_QueryInterface(d3d_device, &IID_IDXGIDevice, (void **)&dxgi_device);
+ hr = ID3D10Device1_QueryInterface(ctx.device, &IID_IDXGIDevice, (void **)&dxgi_device);
ok(SUCCEEDED(hr), "Failed to get IDXGIDevice interface, hr %#x.\n", hr);
hr = ID2D1Factory1_CreateDevice(factory, dxgi_device, &device);
@@ -8477,7 +8444,7 @@ static void test_device_context(void)
/* DXGI target */
window = create_window();
- swapchain = create_swapchain(d3d_device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -8617,7 +8584,7 @@ todo_wine
ID2D1Device_Release(device);
ID2D1Factory1_Release(factory);
- ID3D10Device1_Release(d3d_device);
+ release_test_context(&ctx);
}
static void test_invert_matrix(void)
@@ -8764,6 +8731,7 @@ static ID2D1DeviceContext *create_device_context(ID2D1Factory1 *factory, ID3D10D
static void test_command_list(void)
{
+ struct d2d1_test_context ctx;
static const DWORD bitmap_data[] =
{
0xffff0000, 0xffffff00, 0xff00ff00, 0xff00ffff,
@@ -8782,7 +8750,6 @@ static void test_command_list(void)
D2D1_BITMAP_PROPERTIES bitmap_desc;
ID2D1StrokeStyle *stroke_style;
ID2D1CommandList *command_list;
- ID3D10Device1 *d3d_device;
ID2D1Geometry *geometry;
ID2D1Factory1 *factory;
ID2D1RenderTarget *rt;
@@ -8796,20 +8763,17 @@ static void test_command_list(void)
ULONG refcount;
HRESULT hr;
- if (!(d3d_device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory)))
{
win_skip("ID2D1Factory1 is not supported.\n");
- ID3D10Device1_Release(d3d_device);
+ release_test_context(&ctx);
return;
}
- device_context = create_device_context(factory, d3d_device);
+ device_context = create_device_context(factory, ctx.device);
ok(device_context != NULL, "Failed to create device context.\n");
hr = ID2D1DeviceContext_CreateCommandList(device_context, &command_list);
@@ -8995,7 +8959,7 @@ todo_wine
ID2D1CommandList_Release(command_list);
/* List created with different context. */
- device_context2 = create_device_context(factory, d3d_device);
+ device_context2 = create_device_context(factory, ctx.device);
ok(device_context2 != NULL, "Failed to create device context.\n");
hr = ID2D1DeviceContext_CreateCommandList(device_context, &command_list);
@@ -9012,6 +8976,7 @@ todo_wine
ID2D1DeviceContext_Release(device_context);
refcount = ID2D1Factory1_Release(factory);
ok(!refcount, "Factory has %u references left.\n", refcount);
+ release_test_context(&ctx);
}
static void test_max_bitmap_size(void)
@@ -9134,11 +9099,11 @@ static void test_max_bitmap_size(void)
static void test_dpi(void)
{
+ struct d2d1_test_context ctx;
D2D1_BITMAP_PROPERTIES1 bitmap_desc;
ID2D1DeviceContext *device_context;
IWICImagingFactory *wic_factory;
IDXGISwapChain *swapchain;
- ID3D10Device1 *d3d_device;
ID2D1Factory1 *factory;
IDXGISurface *surface;
ID2D1Bitmap1 *bitmap;
@@ -9166,25 +9131,22 @@ static void test_dpi(void)
static const float dc_dpi_x = 120.0f, dc_dpi_y = 144.0f;
unsigned int i;
- if (!(d3d_device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory)))
{
win_skip("ID2D1Factory1 is not supported.\n");
- ID3D10Device1_Release(d3d_device);
+ release_test_context(&ctx);
return;
}
window = create_window();
- swapchain = create_swapchain(d3d_device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- device_context = create_device_context(factory, d3d_device);
+ device_context = create_device_context(factory, ctx.device);
ok(!!device_context, "Failed to create device context.\n");
ID2D1DeviceContext_GetDpi(device_context, &dpi_x, &dpi_y);
@@ -9353,18 +9315,18 @@ static void test_dpi(void)
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
ID2D1Factory1_Release(factory);
- ID3D10Device1_Release(d3d_device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
static void test_wic_bitmap_format(void)
{
+ struct d2d1_test_context ctx;
IWICImagingFactory *wic_factory;
IDXGISwapChain *swapchain;
D2D1_PIXEL_FORMAT format;
IWICBitmap *wic_bitmap;
ID2D1RenderTarget *rt;
- ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Bitmap *bitmap;
unsigned int i;
@@ -9383,13 +9345,11 @@ static void test_wic_bitmap_format(void)
{&GUID_WICPixelFormat32bppBGR, {DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE}},
};
- if (!(device = create_device()))
- {
- skip("Failed to create device, skipping tests.\n");
+ if (!init_test_context(&ctx))
return;
- }
+
window = create_window();
- swapchain = create_swapchain(device, window, TRUE);
+ swapchain = create_swapchain(ctx.device, window, TRUE);
hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
ok(hr == S_OK, "Failed to get buffer, hr %#x.\n", hr);
rt = create_render_target(surface);
@@ -9424,7 +9384,7 @@ static void test_wic_bitmap_format(void)
ID2D1RenderTarget_Release(rt);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
- ID3D10Device1_Release(device);
+ release_test_context(&ctx);
DestroyWindow(window);
}
--
2.29.2
More information about the wine-devel
mailing list