Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 826526d9d38..5b72d79de0e 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -10764,6 +10764,78 @@ static void test_stroke_contains_point(BOOL d3d11) ID2D1Factory_Release(factory); }
+static void test_image_bounds(BOOL d3d11) +{ + D2D1_BITMAP_PROPERTIES bitmap_desc; + D2D_RECT_F bounds, expected_bounds; + struct d2d1_test_context ctx; + ID2D1DeviceContext *context; + ID2D1Factory1 *factory; + ID2D1Bitmap *bitmap; + D2D1_SIZE_F size; + unsigned int i; + HRESULT hr; + + const struct bitmap_bounds_test + { + float dpi_x; + float dpi_y; + D2D_SIZE_U pixel_size; + } + bitmap_bounds_tests[] = + { + {96.0f, 96.0f, {100, 100}}, + {48.0f, 48.0f, {100, 100}}, + {192.0f, 192.0f, {100, 100}}, + {96.0f, 48.0f, {100, 100}}, + {48.0f, 192.0f, {100, 100}}, + {150.0f, 150.0f, {100, 100}}, + {96.0f, 96.0f, {1, 1}}, + {192.0f, 192.0f, {1, 1}}, + }; + + if (!init_test_context(&ctx, d3d11)) + return; + + if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory))) + { + win_skip("ID2D1Factory1 is not supported.\n"); + release_test_context(&ctx); + return; + } + + hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&context); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + for (i = 0; i < ARRAY_SIZE(bitmap_bounds_tests); ++i) + { + const struct bitmap_bounds_test *test = &bitmap_bounds_tests[i]; + winetest_push_context("Test %u", i); + + bitmap_desc.dpiX = test->dpi_x; + bitmap_desc.dpiY = test->dpi_y; + bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; + bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE; + hr = ID2D1RenderTarget_CreateBitmap(ctx.rt, test->pixel_size, NULL, 0, &bitmap_desc, &bitmap); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + set_rect(&bounds, 0.0f, 0.0f, 0.0f, 0.0f); + size = ID2D1Bitmap_GetSize(bitmap); + ID2D1DeviceContext_GetImageLocalBounds(context, (ID2D1Image *)bitmap, &bounds); + todo_wine ok(compare_rect(&bounds, 0.0f, 0.0f, size.width, size.height, 0), + "Got unexpected bounds {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n", + bounds.left, bounds.top, bounds.right, bounds.bottom, + expected_bounds.left, expected_bounds.top, expected_bounds.right, expected_bounds.bottom); + + ID2D1Bitmap_Release(bitmap); + winetest_pop_context(); + } + + ID2D1DeviceContext_Release(context); + ID2D1Factory1_Release(factory); + release_test_context(&ctx); +} + START_TEST(d2d1) { HMODULE d2d1_dll = GetModuleHandleA("d2d1.dll"); @@ -10835,6 +10907,7 @@ START_TEST(d2d1) queue_test(test_effect_crop); queue_test(test_effect_grayscale); queue_d3d10_test(test_stroke_contains_point); + queue_test(test_image_bounds);
run_queued_tests(); }