From: Ziqing Hui zhui@codeweavers.com
Signed-off-by: Ziqing Hui zhui@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 0a8245d6805..d256fcb2cc2 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); }
@@ -9768,13 +9767,11 @@ static void test_unit_mode(BOOL d3d11) struct d2d1_test_context ctx; ID2D1DeviceContext *context; D2D1_UNIT_MODE unit_mode; - HRESULT hr;
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 +9788,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 +10207,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 +10351,6 @@ static void test_effect(BOOL d3d11) winetest_pop_context(); }
- ID2D1DeviceContext_Release(context); ID2D1Factory1_Release(factory); release_test_context(&ctx); } @@ -10674,8 +10668,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 +10732,6 @@ static void test_effect_2d_affine(BOOL d3d11) }
ID2D1Effect_Release(effect); - ID2D1DeviceContext_Release(context); ID2D1Factory1_Release(factory); release_test_context(&ctx); } @@ -10786,8 +10778,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 +10819,6 @@ static void test_effect_crop(BOOL d3d11) }
ID2D1Effect_Release(effect); - ID2D1DeviceContext_Release(context); ID2D1Factory1_Release(factory); release_test_context(&ctx); } @@ -10860,8 +10850,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 +10895,6 @@ static void test_effect_grayscale(BOOL d3d11) }
ID2D1Effect_Release(effect); - ID2D1DeviceContext_Release(context); ID2D1Factory3_Release(factory); release_test_context(&ctx); } @@ -11269,8 +11257,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 +11302,6 @@ static void test_image_bounds(BOOL d3d11) winetest_pop_context(); }
- ID2D1DeviceContext_Release(context); ID2D1Factory1_Release(factory); release_test_context(&ctx); }
From: Ziqing Hui zhui@codeweavers.com
Signed-off-by: Ziqing Hui zhui@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 119 +++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 75 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index d256fcb2cc2..9c2bc1cdb99 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 @@ -1027,13 +1031,17 @@ static ID2D1RenderTarget *create_render_target(IDXGISurface *surface, BOOL d3d11 #define release_test_context(ctx) release_test_context_(__LINE__, ctx) static void release_test_context_(unsigned int line, struct d2d1_test_context *ctx) { - 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 +1088,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 +1671,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 +1821,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 +1885,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 +2290,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 +2312,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 +2622,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 +2646,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 +2817,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 +2843,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 +3338,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 +4127,6 @@ static void test_path_geometry(BOOL d3d11) ID2D1PathGeometry_Release(geometry);
ID2D1SolidColorBrush_Release(brush); - ID2D1Factory_Release(factory); release_test_context(&ctx); }
@@ -5175,7 +5179,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 +5311,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 +6367,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 +7290,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 +7316,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 +8087,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 +8232,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 +8255,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 +8275,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 +8388,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); }
@@ -10130,39 +10129,9 @@ 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; + unsigned int i, j, min_inputs, max_inputs, str_size, input_count; D2D1_BITMAP_PROPERTIES bitmap_desc; D2D1_BUFFER_PRECISION precision; ID2D1Image *image_a, *image_b; @@ -10198,14 +10167,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;
@@ -10213,7 +10183,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); @@ -10351,7 +10321,6 @@ static void test_effect(BOOL d3d11) winetest_pop_context(); }
- ID2D1Factory1_Release(factory); release_test_context(&ctx); }
@@ -10525,7 +10494,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); @@ -10586,7 +10556,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); }
@@ -10661,7 +10630,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); @@ -10732,7 +10702,6 @@ static void test_effect_2d_affine(BOOL d3d11) }
ID2D1Effect_Release(effect); - ID2D1Factory1_Release(factory); release_test_context(&ctx); }
@@ -10771,7 +10740,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); @@ -10819,7 +10789,6 @@ static void test_effect_crop(BOOL d3d11) }
ID2D1Effect_Release(effect); - ID2D1Factory1_Release(factory); release_test_context(&ctx); }
@@ -10843,7 +10812,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); @@ -10895,7 +10865,6 @@ static void test_effect_grayscale(BOOL d3d11) }
ID2D1Effect_Release(effect); - ID2D1Factory3_Release(factory); release_test_context(&ctx); }
@@ -11250,7 +11219,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); @@ -11302,7 +11272,6 @@ static void test_image_bounds(BOOL d3d11) winetest_pop_context(); }
- ID2D1Factory1_Release(factory); release_test_context(&ctx); }
From: Ziqing Hui zhui@codeweavers.com
Signed-off-by: Ziqing Hui zhui@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 114 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 9c2bc1cdb99..d5adb0c749c 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); @@ -10559,6 +10594,84 @@ static void test_effect_register(BOOL d3d11) release_test_context(&ctx); }
+static void test_effect_context(BOOL d3d11) +{ + 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; + } + + 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(ctx.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); + hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect); + todo_wine + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + release_test_context(&ctx); +} + static void test_effect_2d_affine(BOOL d3d11) { D2D1_MATRIX_3X2_F rotate, scale, skew; @@ -11344,6 +11457,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);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/d2d1_private.h | 2 +- dlls/d2d1/effect.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 9564f19a3cf..8edfa030ee1 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -582,7 +582,7 @@ void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *factory, IDXGIDev
struct d2d_shader { - const GUID *id; + GUID id; IUnknown *shader; };
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index b87ae6bb77d..eceb6234193 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -214,7 +214,7 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadVertexShader(ID2D1Effect
effect_context->shader_count++; shader = &effect_context->shaders[effect_context->shader_count - 1]; - shader->id = shader_id; + shader->id = *shader_id; shader->shader = (IUnknown *)vertex_shader;
return S_OK;
From: Ziqing Hui zhui@codeweavers.com
Signed-off-by: Ziqing Hui zhui@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/effect.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index eceb6234193..ff808475a78 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -195,6 +195,9 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadVertexShader(ID2D1Effect TRACE("iface %p, shader_id %s, buffer %p, buffer_size %u.\n", iface, debugstr_guid(shader_id), buffer, buffer_size);
+ if (ID2D1EffectContext_IsShaderLoaded(iface, shader_id)) + return S_OK; + if (FAILED(hr = ID3D11Device1_CreateVertexShader(effect_context->device_context->d3d_device, buffer, buffer_size, NULL, &vertex_shader))) { @@ -231,7 +234,16 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadComputeShader(ID2D1Effec
static BOOL STDMETHODCALLTYPE d2d_effect_context_IsShaderLoaded(ID2D1EffectContext *iface, REFGUID shader_id) { - FIXME("iface %p, shader_id %s stub!\n", iface, debugstr_guid(shader_id)); + struct d2d_effect_context *effect_context = impl_from_ID2D1EffectContext(iface); + size_t i; + + TRACE("iface %p, shader_id %s.\n", iface, debugstr_guid(shader_id)); + + for (i = 0; i < effect_context->shader_count; ++i) + { + if (IsEqualGUID(shader_id, &effect_context->shaders[i].id)) + return TRUE; + }
return FALSE; }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/effect.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index ff808475a78..79d704dd949 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -37,18 +37,35 @@ static inline struct d2d_effect_context *impl_from_ID2D1EffectContext(ID2D1Effec
static void d2d_effect_context_cleanup(struct d2d_effect_context *effect_context) { - unsigned int i; + size_t i;
for (i = 0; i < effect_context->shader_count; ++i) - { - if (effect_context->shaders[i].shader) - IUnknown_Release(effect_context->shaders[i].shader); - } + IUnknown_Release(effect_context->shaders[i].shader); heap_free(effect_context->shaders);
ID2D1DeviceContext_Release(&effect_context->device_context->ID2D1DeviceContext_iface); }
+static HRESULT d2d_effect_context_add_shader(struct d2d_effect_context *effect_context, + REFGUID shader_id, void *shader) +{ + struct d2d_shader *entry; + + if (!d2d_array_reserve((void **)&effect_context->shaders, &effect_context->shaders_size, + effect_context->shader_count + 1, sizeof(*effect_context->shaders))) + { + WARN("Failed to resize shaders array.\n"); + return E_OUTOFMEMORY; + } + + entry = &effect_context->shaders[effect_context->shader_count++]; + entry->id = *shader_id; + entry->shader = shader; + IUnknown_AddRef(entry->shader); + + return S_OK; +} + static HRESULT STDMETHODCALLTYPE d2d_effect_context_QueryInterface(ID2D1EffectContext *iface, REFIID iid, void **out) { TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); @@ -189,7 +206,6 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadVertexShader(ID2D1Effect { struct d2d_effect_context *effect_context = impl_from_ID2D1EffectContext(iface); ID3D11VertexShader *vertex_shader; - struct d2d_shader *shader; HRESULT hr;
TRACE("iface %p, shader_id %s, buffer %p, buffer_size %u.\n", @@ -205,22 +221,10 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadVertexShader(ID2D1Effect return hr; }
- if (!d2d_array_reserve((void **)&effect_context->shaders, &effect_context->shaders_size, - effect_context->shader_count + 1, sizeof(*effect_context->shaders))) - { - ERR("Failed to resize shaders array.\n"); - ID3D11VertexShader_Release(vertex_shader); - return E_OUTOFMEMORY; - } - memset(effect_context->shaders + effect_context->shader_count, 0, - sizeof(*effect_context->shaders) * (effect_context->shaders_size - effect_context->shader_count)); + hr = d2d_effect_context_add_shader(effect_context, shader_id, vertex_shader); + ID3D11VertexShader_Release(vertex_shader);
- effect_context->shader_count++; - shader = &effect_context->shaders[effect_context->shader_count - 1]; - shader->id = *shader_id; - shader->shader = (IUnknown *)vertex_shader; - - return S_OK; + return hr; }
static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadComputeShader(ID2D1EffectContext *iface,