Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 47 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index ca80a8e946b..fd4b806278a 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -10413,11 +10413,21 @@ static void test_effect_grayscale(BOOL d3d11) ID2D1Factory3 *factory; ID2D1Bitmap1 *bitmap; ID2D1Effect *effect; + D2D1_RECT_F bounds; ID2D1Image *output; unsigned int i; HRESULT hr;
const DWORD test_pixels[] = {0xffffffff, 0x12345678, 0x89abcdef, 0x77777777, 0xdeadbeef}; + const D2D_SIZE_U test_size[] = + { + {1, 1}, + {2, 4}, + {100, 100}, + {123, 456}, + {2000, 1000}, + {8888, 9999}, + };
if (!init_test_context(&ctx, d3d11)) return; @@ -10435,18 +10445,43 @@ static void test_effect_grayscale(BOOL d3d11) hr = ID2D1DeviceContext_CreateEffect(context, &CLSID_D2D1Grayscale, &effect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; + bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE; + bitmap_desc.dpiX = 96.0f; + bitmap_desc.dpiY = 96.0f; + bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_NONE; + bitmap_desc.colorContext = NULL; + + /* Test output bounds */ + for (i = 0; i < ARRAY_SIZE(test_size); ++i) + { + input_size = test_size[i]; + winetest_push_context("Test %u", i); + + hr = ID2D1DeviceContext_CreateBitmap(context, input_size, NULL, 0, &bitmap_desc, &bitmap); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + ID2D1Effect_SetInput(effect, 0, (ID2D1Image *)bitmap, FALSE); + ID2D1Effect_GetOutput(effect, &output); + + ID2D1DeviceContext_GetImageLocalBounds(context, output, &bounds); + todo_wine ok(compare_rect(&bounds, 0.0f, 0.0f, input_size.width, input_size.height, 0), + "Got unexpected output bounds {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n", + bounds.left, bounds.top, bounds.right, bounds.bottom, + 0.0f, 0.0f, (float)input_size.width, (float)input_size.height); + + ID2D1Image_Release(output); + ID2D1Bitmap1_Release(bitmap); + winetest_pop_context(); + } + + /* Test output pixel */ for (i = 0; i < ARRAY_SIZE(test_pixels); ++i) { DWORD pixel = test_pixels[i]; winetest_push_context("Test %u", i);
set_size_u(&input_size, 1, 1); - bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; - bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE; - bitmap_desc.dpiX = 96.0f; - bitmap_desc.dpiY = 96.0f; - bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_NONE; - bitmap_desc.colorContext = NULL; hr = ID2D1DeviceContext_CreateBitmap(context, input_size, &pixel, sizeof(pixel), &bitmap_desc, &bitmap); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 49 ++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 16 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index fd4b806278a..7af3e6a67f1 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -9955,6 +9955,36 @@ static void test_mt_factory(BOOL d3d11) ID2D1Factory_Release(factory); }
+static void *create_factory(const GUID *iid, UINT32 *factory_version) +{ + void *factory, *tmp; + unsigned int i; + + static const GUID *factory_iid[] = + { + &IID_ID2D1Factory, + &IID_ID2D1Factory1, + &IID_ID2D1Factory2, + &IID_ID2D1Factory3, + }; + + if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, iid, NULL, &factory))) + return NULL; + + if (factory_version) + { + for (i = 0; i < ARRAY_SIZE(factory_iid); ++i) + { + if (FAILED(IUnknown_QueryInterface((IUnknown *)factory, factory_iid[i], &tmp))) + break; + IUnknown_Release((IUnknown *)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; @@ -9963,9 +9993,7 @@ static void test_effect(BOOL d3d11) ID2D1Image *image_a, *image_b; struct d2d1_test_context ctx; ID2D1DeviceContext *context; - ID2D1Factory1 *factory1; - ID2D1Factory2 *factory2; - ID2D1Factory3 *factory3; + ID2D1Factory1 *factory; ID2D1Bitmap *bitmap; ID2D1Effect *effect; D2D1_SIZE_U size; @@ -9995,23 +10023,12 @@ static void test_effect(BOOL d3d11) if (!init_test_context(&ctx, d3d11)) return;
- if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory1))) + if (!(factory = create_factory(&IID_ID2D1Factory1, &factory_version)) || factory_version < 1) { win_skip("ID2D1Factory1 is not supported.\n"); release_test_context(&ctx); return; } - factory_version = 1; - if (SUCCEEDED(ID2D1Factory1_QueryInterface(factory1, &IID_ID2D1Factory2, (void **)&factory2))) - { - ID2D1Factory2_Release(factory2); - factory_version = 2; - } - if (SUCCEEDED(ID2D1Factory1_QueryInterface(factory1, &IID_ID2D1Factory3, (void **)&factory3))) - { - ID2D1Factory3_Release(factory3); - factory_version = 3; - } if (factory_version < 3) win_skip("ID2D1Factory%u is not supported.\n", factory_version + 1);
@@ -10161,7 +10178,7 @@ static void test_effect(BOOL d3d11) }
ID2D1DeviceContext_Release(context); - ID2D1Factory1_Release(factory1); + ID2D1Factory1_Release(factory); release_test_context(&ctx); }
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 85 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 2 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 7af3e6a67f1..441ffc4ac34 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -10851,15 +10851,16 @@ static void test_stroke_contains_point(BOOL d3d11) static void test_image_bounds(BOOL d3d11) { D2D1_BITMAP_PROPERTIES bitmap_desc; + unsigned int i, factory_version; struct d2d1_test_context ctx; ID2D1DeviceContext *context; D2D1_UNIT_MODE unit_mode; ID2D1Factory1 *factory; ID2D1Bitmap *bitmap; + ID2D1Effect *effect; float dpi_x, dpi_y; D2D_RECT_F bounds; D2D1_SIZE_F size; - unsigned int i; HRESULT hr;
const struct bitmap_bounds_test @@ -10880,15 +10881,33 @@ static void test_image_bounds(BOOL d3d11) {192.0f, 192.0f, {1, 1}}, };
+ const struct effect_bounds_test + { + const CLSID *clsid; + UINT32 factory_version; + BOOL todo; + } + effect_bounds_tests[] = + { + {&CLSID_D2D12DAffineTransform, 1, TRUE}, + {&CLSID_D2D13DPerspectiveTransform, 1, TRUE}, + {&CLSID_D2D1Composite, 1, TRUE}, + {&CLSID_D2D1Crop, 1, TRUE}, + {&CLSID_D2D1Shadow, 1, TRUE}, + {&CLSID_D2D1Grayscale, 3, TRUE}, + }; + if (!init_test_context(&ctx, d3d11)) return;
- if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory))) + if (!(factory = create_factory(&IID_ID2D1Factory1, &factory_version)) || factory_version < 1) { 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);
hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&context); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); @@ -10936,6 +10955,68 @@ static void test_image_bounds(BOOL d3d11) winetest_pop_context(); }
+ for (i = 0; i < ARRAY_SIZE(effect_bounds_tests); ++i) + { + const struct effect_bounds_test *test = &effect_bounds_tests[i]; + D2D1_SIZE_U bitmap_size; + ID2D1Image *output; + + if (factory_version < test->factory_version) + continue; + + winetest_push_context("Test %u", i); + + hr = ID2D1DeviceContext_CreateEffect(context, test->clsid, &effect); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ID2D1Effect_GetOutput(effect, &output); + + /* Test effect bounds without setting any input image */ + set_rect(&bounds, 0.0f, 0.0f, 0.0f, 0.0f); + ID2D1DeviceContext_GetImageLocalBounds(context, output, &bounds); + ok(compare_rect(&bounds, 0.0f, 0.0f, 0.0f, 0.0f, 0), + "Got unexpected output bounds {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n", + bounds.left, bounds.top, bounds.right, bounds.bottom, + 0.0f, 0.0f, 0.0f, 0.0f); + + set_rect(&bounds, -1.0f, -1.0f, -1.0f, -1.0f); + ID2D1DeviceContext_GetImageLocalBounds(context, output, &bounds); + ok(compare_rect(&bounds, -1.0f, -1.0f, -1.0f, -1.0f, 0), + "Got unexpected output bounds {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n", + bounds.left, bounds.top, bounds.right, bounds.bottom, + -1.0f, -1.0f, -1.0f, -1.0f); + + /* Test effect bounds after setting an input image */ + bitmap_desc.dpiX = 96.0f; + bitmap_desc.dpiY = 96.0f; + bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; + bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE; + set_size_u(&bitmap_size, 100, 100); + hr = ID2D1RenderTarget_CreateBitmap(ctx.rt, bitmap_size, NULL, 0, &bitmap_desc, &bitmap); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + ID2D1Effect_SetInput(effect, 0, (ID2D1Image *)bitmap, FALSE); + set_rect(&bounds, -1.0f, -1.0f, -1.0f, -1.0f); + ID2D1DeviceContext_GetImageLocalBounds(context, output, &bounds); + if (ID2D1Effect_GetInputCount(effect) > 1) + { + ok(compare_rect(&bounds, -1.0f, -1.0f, -1.0f, -1.0f, 0), + "Got unexpected output bounds {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n", + bounds.left, bounds.top, bounds.right, bounds.bottom, + -1.0f, -1.0f, -1.0f, -1.0f); + } + else + { + todo_wine_if(test->todo) + ok(!compare_rect(&bounds, -1.0f, -1.0f, -1.0f, -1.0f, 0), + "Got unexpected output bounds {-1.0, -1.0, -1.0, -1.0}.\n"); + } + + ID2D1Bitmap_Release(bitmap); + ID2D1Image_Release(output); + ID2D1Effect_Release(effect); + winetest_pop_context(); + } + ID2D1DeviceContext_Release(context); ID2D1Factory1_Release(factory); release_test_context(&ctx);
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=112916
Your paranoid android.
=== debian11 (64 bit WoW report) ===
d2d1: d2d1.c:6870: Test failed: d2d1.c:9303: Tests skipped: Failed to create REF d3d device, hr 0x80004005.
Report validation errors: d2d1:d2d1 is missing some skip messages
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/d2d1_private.h | 1 + dlls/d2d1/effect.c | 8 ++++++++ 2 files changed, 9 insertions(+)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index aa8e8569455..53c96461bab 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -590,6 +590,7 @@ struct d2d_effect };
HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory, const CLSID *effect_id) DECLSPEC_HIDDEN; +struct d2d_effect *unsafe_impl_from_ID2D1Effect(ID2D1Effect *iface) DECLSPEC_HIDDEN;
static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size) { diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index 601932b005b..0bf13c22bab 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -394,3 +394,11 @@ HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory, const WARN("Unsupported effect clsid %s.\n", debugstr_guid(effect_id)); return E_FAIL; } + +struct d2d_effect *unsafe_impl_from_ID2D1Effect(ID2D1Effect *iface) +{ + if (!iface) + return NULL; + assert(iface->lpVtbl == (ID2D1EffectVtbl *)&d2d_effect_vtbl); + return CONTAINING_RECORD(iface, struct d2d_effect, ID2D1Effect_iface); +}
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/device.c | 32 ++++++++++++++++++++++++++++++-- dlls/d2d1/tests/d2d1.c | 4 ++-- 2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 13c99458cfa..99fab24125b 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1979,9 +1979,12 @@ static void STDMETHODCALLTYPE d2d_device_context_GetImageLocalBounds(ID2D1Device ID2D1Image *image, D2D1_RECT_F *local_bounds) { struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); + ID2D1Bitmap *bitmap = NULL; + ID2D1Effect *effect = NULL; D2D_SIZE_U pixel_size; - ID2D1Bitmap *bitmap; + const CLSID *clsid; D2D_SIZE_F size; + unsigned int i;
TRACE("iface %p, image %p, local_bounds %p.\n", iface, image, local_bounds);
@@ -2007,12 +2010,37 @@ static void STDMETHODCALLTYPE d2d_device_context_GetImageLocalBounds(ID2D1Device WARN("Unknown unit mode %#x.\n", context->drawing_state.unitMode); break; } - ID2D1Bitmap_Release(bitmap); + } + else if (SUCCEEDED(ID2D1Image_QueryInterface(image, &IID_ID2D1Effect, (void **)&effect))) + { + struct d2d_effect *effect_impl = unsafe_impl_from_ID2D1Effect(effect); + + for (i = 0; i < effect_impl->input_count; ++i) + { + if (!effect_impl->inputs[i]) + goto done; + } + + clsid = effect_impl->info->clsid; + if (IsEqualGUID(clsid, &CLSID_D2D1Grayscale)) + { + ID2D1DeviceContext_GetImageLocalBounds(iface, (ID2D1Image *)effect_impl->inputs[0], local_bounds); + } + else + { + FIXME("Unable to get local bounds of effect %s.\n", debugstr_guid(clsid)); + } } else { FIXME("Unable to get local bounds of image %p.\n", image); } + +done: + if (effect) + ID2D1Effect_Release(effect); + if (bitmap) + ID2D1Bitmap_Release(bitmap); }
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetImageWorldBounds(ID2D1DeviceContext *iface, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 441ffc4ac34..9944d409017 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -10482,7 +10482,7 @@ static void test_effect_grayscale(BOOL d3d11) ID2D1Effect_GetOutput(effect, &output);
ID2D1DeviceContext_GetImageLocalBounds(context, output, &bounds); - todo_wine ok(compare_rect(&bounds, 0.0f, 0.0f, input_size.width, input_size.height, 0), + ok(compare_rect(&bounds, 0.0f, 0.0f, input_size.width, input_size.height, 0), "Got unexpected output bounds {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n", bounds.left, bounds.top, bounds.right, bounds.bottom, 0.0f, 0.0f, (float)input_size.width, (float)input_size.height); @@ -10894,7 +10894,7 @@ static void test_image_bounds(BOOL d3d11) {&CLSID_D2D1Composite, 1, TRUE}, {&CLSID_D2D1Crop, 1, TRUE}, {&CLSID_D2D1Shadow, 1, TRUE}, - {&CLSID_D2D1Grayscale, 3, TRUE}, + {&CLSID_D2D1Grayscale, 3}, };
if (!init_test_context(&ctx, d3d11))