Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 0a8245d6805..c81c967e55e 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -111,6 +111,7 @@ struct d2d1_test_context IDXGISwapChain *swapchain; IDXGISurface *surface; ID2D1RenderTarget *rt; + ID2D1DeviceContext *context; };
struct resource_readback @@ -1029,6 +1030,7 @@ static void release_test_context_(unsigned int line, struct d2d1_test_context *c ID2D1Factory *factory; ULONG ref;
+ ID2D1DeviceContext_Release(ctx->context); ID2D1RenderTarget_GetFactory(ctx->rt, &factory); ID2D1RenderTarget_Release(ctx->rt); ref = ID2D1Factory_Release(factory); @@ -1075,6 +1077,9 @@ static BOOL init_test_context_(unsigned int line, struct d2d1_test_context *ctx, } ok_(__FILE__, line)(!!ctx->rt, "Failed to create render target.\n");
+ hr = ID2D1RenderTarget_QueryInterface(ctx->rt, &IID_ID2D1DeviceContext, (void **)&ctx->context); + ok_(__FILE__, line)(hr == S_OK, "Failed to get device context, hr %#lx.\n", hr); + return TRUE; }
@@ -2036,13 +2041,10 @@ static void test_bitmap_brush(BOOL d3d11) ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Vista */, "Got unexpected hr %#lx.\n", hr); if (hr == S_OK) { - ID2D1DeviceContext *context; + ID2D1DeviceContext *context = ctx.context; D2D1_POINT_2F offset; D2D1_RECT_F src_rect;
- hr = ID2D1RenderTarget_QueryInterface(rt, &IID_ID2D1DeviceContext, (void **)&context); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - ID2D1RenderTarget_BeginDraw(rt); set_color(&color, 0.0f, 0.0f, 1.0f, 1.0f); ID2D1RenderTarget_Clear(rt, &color); @@ -2111,7 +2113,6 @@ static void test_bitmap_brush(BOOL d3d11) ok(match, "Surface does not match.\n");
ID2D1RenderTarget_SetTransform(rt, &tmp_matrix); - ID2D1DeviceContext_Release(context); ID2D1Image_Release(image); }
@@ -2393,8 +2394,7 @@ static void test_image_brush(BOOL d3d11) if (!init_test_context(&ctx, d3d11)) return;
- hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&device_context); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + device_context = ctx.context;
set_size_u(&size, 4, 4); bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; @@ -2466,7 +2466,6 @@ static void test_image_brush(BOOL d3d11) refcount = ID2D1Bitmap_Release(bitmap); ok(!refcount, "Bitmap has %lu references left.\n", refcount);
- ID2D1DeviceContext_Release(device_context); release_test_context(&ctx); }
@@ -9773,8 +9772,7 @@ static void test_unit_mode(BOOL d3d11) if (!init_test_context(&ctx, d3d11)) return;
- hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&context); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + context = ctx.context;
unit_mode = ID2D1DeviceContext_GetUnitMode(context); ok(unit_mode == D2D1_UNIT_MODE_DIPS, "Got unexpected unit mode %#x.\n", unit_mode); @@ -9791,7 +9789,6 @@ static void test_unit_mode(BOOL d3d11) unit_mode = ID2D1DeviceContext_GetUnitMode(context); ok(unit_mode == D2D1_UNIT_MODE_PIXELS, "Got unexpected unit mode %#x.\n", unit_mode);
- ID2D1DeviceContext_Release(context); release_test_context(&ctx); }
@@ -10211,8 +10208,7 @@ static void test_effect(BOOL d3d11) if (factory_version < 3) win_skip("ID2D1Factory%u is not supported.\n", factory_version + 1);
- hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&context); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + context = ctx.context;
for (i = 0; i < ARRAY_SIZE(effect_tests); ++i) { @@ -10356,7 +10352,6 @@ static void test_effect(BOOL d3d11) winetest_pop_context(); }
- ID2D1DeviceContext_Release(context); ID2D1Factory1_Release(factory); release_test_context(&ctx); } @@ -10674,8 +10669,7 @@ static void test_effect_2d_affine(BOOL d3d11) return; }
- hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&context); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + context = ctx.context;
hr = ID2D1DeviceContext_CreateEffect(context, &CLSID_D2D12DAffineTransform, &effect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); @@ -10739,7 +10733,6 @@ static void test_effect_2d_affine(BOOL d3d11) }
ID2D1Effect_Release(effect); - ID2D1DeviceContext_Release(context); ID2D1Factory1_Release(factory); release_test_context(&ctx); } @@ -10786,8 +10779,7 @@ static void test_effect_crop(BOOL d3d11) return; }
- hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&context); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + context = ctx.context;
hr = ID2D1DeviceContext_CreateEffect(context, &CLSID_D2D1Crop, &effect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); @@ -10828,7 +10820,6 @@ static void test_effect_crop(BOOL d3d11) }
ID2D1Effect_Release(effect); - ID2D1DeviceContext_Release(context); ID2D1Factory1_Release(factory); release_test_context(&ctx); } @@ -10860,8 +10851,7 @@ static void test_effect_grayscale(BOOL d3d11) return; }
- hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&context); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + context = ctx.context;
hr = ID2D1DeviceContext_CreateEffect(context, &CLSID_D2D1Grayscale, &effect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); @@ -10906,7 +10896,6 @@ static void test_effect_grayscale(BOOL d3d11) }
ID2D1Effect_Release(effect); - ID2D1DeviceContext_Release(context); ID2D1Factory3_Release(factory); release_test_context(&ctx); } @@ -11269,8 +11258,7 @@ static void test_image_bounds(BOOL d3d11) return; }
- hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&context); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + context = ctx.context;
for (i = 0; i < ARRAY_SIZE(bitmap_bounds_tests); ++i) { @@ -11315,7 +11303,6 @@ static void test_image_bounds(BOOL d3d11) winetest_pop_context(); }
- ID2D1DeviceContext_Release(context); ID2D1Factory1_Release(factory); release_test_context(&ctx); }
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 116 +++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 73 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index c81c967e55e..72a6bb9bb7c 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -112,6 +112,10 @@ struct d2d1_test_context IDXGISurface *surface; ID2D1RenderTarget *rt; ID2D1DeviceContext *context; + ID2D1Factory *factory; + ID2D1Factory1 *factory1; + ID2D1Factory2 *factory2; + ID2D1Factory3 *factory3; };
struct resource_readback @@ -1030,10 +1034,15 @@ static void release_test_context_(unsigned int line, struct d2d1_test_context *c ID2D1Factory *factory; ULONG ref;
+ if (ctx->factory3) + ID2D1Factory3_Release(ctx->factory3); + if (ctx->factory2) + ID2D1Factory2_Release(ctx->factory2); + if (ctx->factory1) + ID2D1Factory1_Release(ctx->factory1); ID2D1DeviceContext_Release(ctx->context); - ID2D1RenderTarget_GetFactory(ctx->rt, &factory); ID2D1RenderTarget_Release(ctx->rt); - ref = ID2D1Factory_Release(factory); + ref = ID2D1Factory_Release(ctx->factory); ok_(__FILE__, line)(!ref, "Factory has %lu references left.\n", ref);
IDXGISurface_Release(ctx->surface); @@ -1080,6 +1089,11 @@ static BOOL init_test_context_(unsigned int line, struct d2d1_test_context *ctx, hr = ID2D1RenderTarget_QueryInterface(ctx->rt, &IID_ID2D1DeviceContext, (void **)&ctx->context); ok_(__FILE__, line)(hr == S_OK, "Failed to get device context, hr %#lx.\n", hr);
+ ID2D1RenderTarget_GetFactory(ctx->rt, &ctx->factory); + ID2D1Factory_QueryInterface(ctx->factory, &IID_ID2D1Factory1, (void **)&ctx->factory1); + ID2D1Factory_QueryInterface(ctx->factory, &IID_ID2D1Factory2, (void **)&ctx->factory2); + ID2D1Factory_QueryInterface(ctx->factory, &IID_ID2D1Factory3, (void **)&ctx->factory3); + return TRUE; }
@@ -1658,7 +1672,8 @@ static void test_state_block(BOOL d3d11) return;
rt = ctx.rt; - ID2D1RenderTarget_GetFactory(rt, &factory); + factory = ctx.factory; + factory1 = ctx.factory1; hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory, (IUnknown **)&dwrite_factory); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); hr = IDWriteFactory_CreateRenderingParams(dwrite_factory, &text_rendering_params1); @@ -1807,7 +1822,7 @@ static void test_state_block(BOOL d3d11) text_rendering_params2, text_rendering_params1); IDWriteRenderingParams_Release(text_rendering_params2);
- if (SUCCEEDED(ID2D1Factory_QueryInterface(factory, &IID_ID2D1Factory1, (void **)&factory1))) + if (factory1) { D2D1_DRAWING_STATE_DESCRIPTION1 drawing_state1; ID2D1DrawingStateBlock1 *state_block1; @@ -1871,15 +1886,12 @@ static void test_state_block(BOOL d3d11) ID2D1DrawingStateBlock1_GetTextRenderingParams(state_block1, &text_rendering_params2); ok(!text_rendering_params2, "Got unexpected text rendering params %p.\n", text_rendering_params2); ID2D1DrawingStateBlock1_Release(state_block1); - - ID2D1Factory1_Release(factory1); }
ID2D1DrawingStateBlock_Release(state_block);
refcount = IDWriteRenderingParams_Release(text_rendering_params1); ok(!refcount, "Rendering params %lu references left.\n", refcount); - ID2D1Factory_Release(factory); release_test_context(&ctx); }
@@ -2279,7 +2291,7 @@ static void test_bitmap_brush(BOOL d3d11) set_rect(&dst_rect, 0.0f, 0.0f, 80.0f, 240.0f); ID2D1RenderTarget_FillRectangle(rt, &dst_rect, (ID2D1Brush *)brush);
- ID2D1RenderTarget_GetFactory(rt, &factory); + factory = ctx.factory;
set_rect(&dst_rect, -1.0f, -1.0f, 1.0f, 1.0f); hr = ID2D1Factory_CreateRectangleGeometry(factory, &dst_rect, &rectangle_geometry); @@ -2301,8 +2313,6 @@ static void test_bitmap_brush(BOOL d3d11) ID2D1RenderTarget_FillGeometry(rt, (ID2D1Geometry *)transformed_geometry, (ID2D1Brush *)brush, NULL); ID2D1TransformedGeometry_Release(transformed_geometry);
- ID2D1Factory_Release(factory); - hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); match = compare_surface(&ctx, "cf7b90ba7b139fdfbe9347e1907d635cfb4ed197"); @@ -2613,7 +2623,7 @@ static void test_linear_brush(BOOL d3d11) set_rect(&r, -80.0f, -60.0f, 80.0f, 60.0f); ID2D1RenderTarget_FillRectangle(rt, &r, (ID2D1Brush *)brush);
- ID2D1RenderTarget_GetFactory(rt, &factory); + factory = ctx.factory;
set_rect(&r, -1.0f, -1.0f, 1.0f, 1.0f); hr = ID2D1Factory_CreateRectangleGeometry(factory, &r, &rectangle_geometry); @@ -2637,8 +2647,6 @@ static void test_linear_brush(BOOL d3d11) ID2D1RenderTarget_FillGeometry(rt, (ID2D1Geometry *)transformed_geometry, (ID2D1Brush *)brush, NULL); ID2D1TransformedGeometry_Release(transformed_geometry);
- ID2D1Factory_Release(factory); - hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
@@ -2810,7 +2818,7 @@ static void test_radial_brush(BOOL d3d11) set_rect(&r, -80.0f, -60.0f, 80.0f, 60.0f); ID2D1RenderTarget_FillRectangle(rt, &r, (ID2D1Brush *)brush);
- ID2D1RenderTarget_GetFactory(rt, &factory); + factory = ctx.factory;
set_rect(&r, -1.0f, -1.0f, 1.0f, 1.0f); hr = ID2D1Factory_CreateRectangleGeometry(factory, &r, &rectangle_geometry); @@ -2836,8 +2844,6 @@ static void test_radial_brush(BOOL d3d11) ID2D1RenderTarget_FillGeometry(rt, (ID2D1Geometry *)transformed_geometry, (ID2D1Brush *)brush, NULL); ID2D1TransformedGeometry_Release(transformed_geometry);
- ID2D1Factory_Release(factory); - hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
@@ -3333,7 +3339,7 @@ static void test_path_geometry(BOOL d3d11) return;
rt = ctx.rt; - ID2D1RenderTarget_GetFactory(rt, &factory); + factory = ctx.factory;
ID2D1RenderTarget_SetDpi(rt, 192.0f, 48.0f); ID2D1RenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_ALIASED); @@ -4122,7 +4128,6 @@ static void test_path_geometry(BOOL d3d11) ID2D1PathGeometry_Release(geometry);
ID2D1SolidColorBrush_Release(brush); - ID2D1Factory_Release(factory); release_test_context(&ctx); }
@@ -5175,7 +5180,7 @@ static void test_opacity_brush(BOOL d3d11) return;
rt = ctx.rt; - ID2D1RenderTarget_GetFactory(rt, &factory); + factory = ctx.factory;
ID2D1RenderTarget_SetDpi(rt, 192.0f, 48.0f); ID2D1RenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_ALIASED); @@ -5307,7 +5312,6 @@ static void test_opacity_brush(BOOL d3d11) ID2D1BitmapBrush_Release(bitmap_brush); ID2D1BitmapBrush_Release(opacity_brush); ID2D1SolidColorBrush_Release(color_brush); - ID2D1Factory_Release(factory); release_test_context(&ctx); }
@@ -6364,7 +6368,7 @@ static void test_draw_geometry(BOOL d3d11) return;
rt = ctx.rt; - ID2D1RenderTarget_GetFactory(rt, &factory); + factory = ctx.factory;
ID2D1RenderTarget_SetDpi(rt, 192.0f, 48.0f); ID2D1RenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_ALIASED); @@ -7287,7 +7291,6 @@ static void test_draw_geometry(BOOL d3d11) ok(match, "Figure does not match.\n");
ID2D1SolidColorBrush_Release(brush); - ID2D1Factory_Release(factory); release_test_context(&ctx); }
@@ -7314,7 +7317,7 @@ static void test_fill_geometry(BOOL d3d11) return;
rt = ctx.rt; - ID2D1RenderTarget_GetFactory(rt, &factory); + factory = ctx.factory;
ID2D1RenderTarget_SetDpi(rt, 192.0f, 48.0f); ID2D1RenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_ALIASED); @@ -8085,7 +8088,6 @@ static void test_fill_geometry(BOOL d3d11) ok(match, "Figure does not match.\n");
ID2D1SolidColorBrush_Release(brush); - ID2D1Factory_Release(factory); release_test_context(&ctx); }
@@ -8231,7 +8233,7 @@ static void test_layer(BOOL d3d11) return;
rt = ctx.rt; - ID2D1RenderTarget_GetFactory(rt, &factory); + factory = ctx.factory;
ID2D1RenderTarget_SetDpi(rt, 192.0f, 48.0f); ID2D1RenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_ALIASED); @@ -8254,7 +8256,6 @@ static void test_layer(BOOL d3d11) ok(size.height == 600.0f, "Got unexpected height %.8e.\n", size.height); ID2D1Layer_Release(layer);
- ID2D1Factory_Release(factory); release_test_context(&ctx); }
@@ -8275,7 +8276,7 @@ static void test_bezier_intersect(BOOL d3d11) return;
rt = ctx.rt; - ID2D1RenderTarget_GetFactory(rt, &factory); + factory = ctx.factory;
ID2D1RenderTarget_SetDpi(rt, 192.0f, 48.0f); ID2D1RenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_ALIASED); @@ -8388,7 +8389,6 @@ static void test_bezier_intersect(BOOL d3d11) ok(match, "Figure does not match.\n");
ID2D1SolidColorBrush_Release(brush); - ID2D1Factory_Release(factory); release_test_context(&ctx); }
@@ -10131,36 +10131,6 @@ static void test_mt_factory(BOOL d3d11) ID2D1Factory_Release(factory); }
-static void *create_factory(const GUID *iid, UINT32 *factory_version) -{ - IUnknown *factory, *tmp; - unsigned int i; - - static const GUID *const factory_iid[] = - { - &IID_ID2D1Factory, - &IID_ID2D1Factory1, - &IID_ID2D1Factory2, - &IID_ID2D1Factory3, - }; - - if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, iid, NULL, (void **)&factory))) - return NULL; - - if (factory_version) - { - for (i = 0; i < ARRAY_SIZE(factory_iid); ++i) - { - if (FAILED(IUnknown_QueryInterface(factory, factory_iid[i], (void **)&tmp))) - break; - IUnknown_Release(tmp); - } - *factory_version = i - 1; - } - - return factory; -} - static void test_effect(BOOL d3d11) { unsigned int i, j, min_inputs, max_inputs, str_size, input_count, factory_version; @@ -10199,14 +10169,15 @@ static void test_effect(BOOL d3d11) if (!init_test_context(&ctx, d3d11)) return;
- if (!(factory = create_factory(&IID_ID2D1Factory1, &factory_version))) + factory = ctx.factory1; + if (!factory) { win_skip("ID2D1Factory1 is not supported.\n"); release_test_context(&ctx); return; } - if (factory_version < 3) - win_skip("ID2D1Factory%u is not supported.\n", factory_version + 1); + if (!ctx.factory3) + win_skip("ID2D1Factory3 is not supported.\n");
context = ctx.context;
@@ -10214,7 +10185,7 @@ static void test_effect(BOOL d3d11) { const struct effect_test *test = effect_tests + i;
- if (factory_version < test->factory_version) + if (test->factory_version == 3 && !ctx.factory3) continue;
winetest_push_context("Test %u", i); @@ -10352,7 +10323,6 @@ static void test_effect(BOOL d3d11) winetest_pop_context(); }
- ID2D1Factory1_Release(factory); release_test_context(&ctx); }
@@ -10526,7 +10496,8 @@ static void test_effect_register(BOOL d3d11) if (!init_test_context(&ctx, d3d11)) return;
- if (!(factory = create_factory(&IID_ID2D1Factory1, NULL))) + factory = ctx.factory1; + if (!factory) { win_skip("ID2D1Factory1 is not supported.\n"); release_test_context(&ctx); @@ -10587,7 +10558,6 @@ static void test_effect_register(BOOL d3d11) hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_D2D1Composite); todo_wine ok(hr == D2DERR_EFFECT_IS_NOT_REGISTERED, "Got unexpected hr %#lx.\n", hr);
- ID2D1Factory1_Release(factory); release_test_context(&ctx); }
@@ -10662,7 +10632,8 @@ static void test_effect_2d_affine(BOOL d3d11) if (!init_test_context(&ctx, d3d11)) return;
- if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory))) + factory = ctx.factory1; + if (!factory) { win_skip("ID2D1Factory1 is not supported.\n"); release_test_context(&ctx); @@ -10733,7 +10704,6 @@ static void test_effect_2d_affine(BOOL d3d11) }
ID2D1Effect_Release(effect); - ID2D1Factory1_Release(factory); release_test_context(&ctx); }
@@ -10772,7 +10742,8 @@ static void test_effect_crop(BOOL d3d11) if (!init_test_context(&ctx, d3d11)) return;
- if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory))) + factory = ctx.factory1; + if (!factory) { win_skip("ID2D1Factory1 is not supported.\n"); release_test_context(&ctx); @@ -10820,7 +10791,6 @@ static void test_effect_crop(BOOL d3d11) }
ID2D1Effect_Release(effect); - ID2D1Factory1_Release(factory); release_test_context(&ctx); }
@@ -10844,7 +10814,8 @@ static void test_effect_grayscale(BOOL d3d11) if (!init_test_context(&ctx, d3d11)) return;
- if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory3, NULL, (void **)&factory))) + factory = ctx.factory3; + if (!factory) { win_skip("ID2D1Factory3 is not supported.\n"); release_test_context(&ctx); @@ -10896,7 +10867,6 @@ static void test_effect_grayscale(BOOL d3d11) }
ID2D1Effect_Release(effect); - ID2D1Factory3_Release(factory); release_test_context(&ctx); }
@@ -11251,7 +11221,8 @@ static void test_image_bounds(BOOL d3d11) if (!init_test_context(&ctx, d3d11)) return;
- if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory))) + factory = ctx.factory1; + if (!factory) { win_skip("ID2D1Factory1 is not supported.\n"); release_test_context(&ctx); @@ -11303,7 +11274,6 @@ static void test_image_bounds(BOOL d3d11) winetest_pop_context(); }
- ID2D1Factory1_Release(factory); release_test_context(&ctx); }
Signed-off-by: Ziqing Hui zhui@codeweavers.com ---
v2: Remove some todo_wine. Get rid of create_factory().
dlls/d2d1/tests/d2d1.c | 117 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 72a6bb9bb7c..036f196f3ca 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -31,6 +31,8 @@ #include "wine/heap.h"
DEFINE_GUID(CLSID_TestEffect, 0xb9ee12e9,0x32d9,0xe659,0xac,0x61,0x2d,0x7c,0xea,0x69,0x28,0x78); +DEFINE_GUID(GUID_TestVertexShader, 0x5bcdcfae,0x1e92,0x4dc1,0x94,0xfa,0x3b,0x01,0xca,0x54,0x59,0x20); +DEFINE_GUID(GUID_TestPixelShader, 0x53015748,0xfc13,0x4168,0xbd,0x13,0x0f,0xcf,0x15,0x29,0x7f,0x01);
static const WCHAR *effect_xml_a = L"<?xml version='1.0'?> \ @@ -86,6 +88,39 @@ L"<?xml version='1.0'?> \ </Effect> \ ";
+static const DWORD test_vs[] = +{ +#if 0 + void main(float4 pos : Position, out float4 output : SV_Position) + { + output = pos; + } +#endif + 0x43425844, 0xa84b398b, 0xc4047d32, 0xc19c67bb, 0x4644285e, 0x00000001, 0x000000d8, 0x00000003, + 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x69736f50, 0x6e6f6974, 0xababab00, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003, + 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x52444853, 0x0000003c, 0x00010040, + 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, + 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, +}; + +static const DWORD test_ps[] = +{ +#if 0 + float4 main() : SV_Target + { + return float4(0.1, 0.2, 0.3, 0.4); + } +#endif + 0x43425844, 0xf34300ae, 0x22fc6d56, 0x5cca66fa, 0x86ae3266, 0x00000001, 0x000000b0, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e, + 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3dcccccd, + 0x3e4ccccd, 0x3e99999a, 0x3ecccccd, 0x0100003e, +}; + static HRESULT (WINAPI *pD2D1CreateDevice)(IDXGIDevice *dxgi_device, const D2D1_CREATION_PROPERTIES *properties, ID2D1Device **device); static void (WINAPI *pD2D1SinCos)(float angle, float *s, float *c); @@ -10561,6 +10596,87 @@ static void test_effect_register(BOOL d3d11) release_test_context(&ctx); }
+static void test_effect_context(BOOL d3d11) +{ + ID2D1DeviceContext *device_context; + ID2D1EffectContext *effect_context; + D2D1_PROPERTY_BINDING binding; + struct d2d1_test_context ctx; + ID2D1Effect *effect = NULL; + ID2D1Factory1 *factory; + BOOL loaded; + HRESULT hr; + + if (!init_test_context(&ctx, d3d11)) + return; + + factory = ctx.factory1; + if (!factory) + { + win_skip("ID2D1Factory1 is not supported.\n"); + release_test_context(&ctx); + return; + } + + hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&device_context); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + binding.propertyName = L"Context"; + binding.setFunction = NULL; + binding.getFunction = effect_impl_get_context; + hr = ID2D1Factory1_RegisterEffectFromString(factory, &CLSID_TestEffect, + effect_xml_b, &binding, 1, effect_impl_create); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = ID2D1DeviceContext_CreateEffect(device_context, &CLSID_TestEffect, &effect); + todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + if (hr != S_OK) + goto done; + hr = ID2D1Effect_GetValueByName(effect, L"Context", + D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + if (hr != S_OK) + goto done; + + /* Test shader loading */ + loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestVertexShader); + ok(!loaded, "Shader is loaded.\n"); + loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestPixelShader); + ok(!loaded, "Shader is loaded.\n"); + + hr = ID2D1EffectContext_LoadVertexShader(effect_context, + &GUID_TestVertexShader, (const BYTE *)test_ps, sizeof(test_ps)); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); + hr = ID2D1EffectContext_LoadVertexShader(effect_context, + &GUID_TestVertexShader, (const BYTE *)test_vs, sizeof(test_vs)); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestVertexShader); + ok(loaded, "Shader is not loaded.\n"); + + hr = ID2D1EffectContext_LoadVertexShader(effect_context, + &GUID_TestVertexShader, (const BYTE *)test_ps, sizeof(test_ps)); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + hr = ID2D1EffectContext_LoadVertexShader(effect_context, + &GUID_TestVertexShader, (const BYTE *)test_vs, sizeof(test_vs)); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = ID2D1EffectContext_LoadPixelShader(effect_context, + &GUID_TestPixelShader, (const BYTE *)test_vs, sizeof(test_vs)); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); + hr = ID2D1EffectContext_LoadPixelShader(effect_context, + &GUID_TestPixelShader, (const BYTE *)test_ps, sizeof(test_ps)); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestPixelShader); + ok(loaded, "Shader is not loaded.\n"); + +done: + if (effect) + ID2D1Effect_Release(effect); + ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect); + ID2D1DeviceContext_Release(device_context); + release_test_context(&ctx); +} + static void test_effect_2d_affine(BOOL d3d11) { D2D1_MATRIX_3X2_F rotate, scale, skew; @@ -11346,6 +11462,7 @@ START_TEST(d2d1) queue_test(test_geometry_group); queue_test(test_mt_factory); queue_test(test_effect_register); + queue_test(test_effect_context); queue_test(test_effect); queue_test(test_effect_2d_affine); queue_test(test_effect_crop);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=115427
Your paranoid android.
=== debian11 (32 bit Chinese:China report) ===
d2d1: Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x7d8642f9).