[PATCH 3/5] d2d1/tests: Test GetImageLocalBounds() for effect.
Ziqing Hui
zhui at codeweavers.com
Wed Apr 20 03:04:27 CDT 2022
Signed-off-by: Ziqing Hui <zhui at 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);
--
2.25.1
More information about the wine-devel
mailing list