[PATCH v6 2/2] d2d1/tests: Add some tests for ID2D1DeviceContext::CreateImageBrush().
Dmitry Timoshkov
dmitry at baikal.ru
Fri May 13 12:25:12 CDT 2022
Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
dlls/d2d1/tests/d2d1.c | 85 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index ca80a8e946b..72869f50132 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -2291,6 +2291,90 @@ static void test_bitmap_brush(BOOL d3d11)
release_test_context(&ctx);
}
+static void test_image_brush(BOOL d3d11)
+{
+ struct d2d1_test_context ctx;
+ ID2D1DeviceContext *device_context;
+ D2D1_BITMAP_PROPERTIES bitmap_desc;
+ ID2D1Bitmap *bitmap;
+ ID2D1Image *image, *tmp_image;
+ D2D1_IMAGE_BRUSH_PROPERTIES image_brush_desc;
+ D2D1_BRUSH_PROPERTIES brush_desc;
+ ID2D1ImageBrush *brush;
+ D2D1_SIZE_U size;
+ ULONG refcount;
+ HRESULT hr;
+ static const DWORD bitmap_data[] =
+ {
+ 0xffff0000, 0xffffff00, 0xff00ff00, 0xff00ffff,
+ 0xff0000ff, 0xffff00ff, 0xff000000, 0xff7f7f7f,
+ 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
+ 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
+ };
+
+ 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);
+
+ ID2D1RenderTarget_SetDpi(ctx.rt, 192.0f, 48.0f);
+ ID2D1RenderTarget_SetAntialiasMode(ctx.rt, D2D1_ANTIALIAS_MODE_ALIASED);
+
+ set_size_u(&size, 4, 4);
+ 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;
+ hr = ID2D1RenderTarget_CreateBitmap(ctx.rt, size, bitmap_data, 4 * sizeof(*bitmap_data), &bitmap_desc, &bitmap);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+ hr = ID2D1Bitmap_QueryInterface(bitmap, &IID_ID2D1Image, (void **)&image);
+ ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Vista */, "Got unexpected hr %#lx.\n", hr);
+ if (hr != S_OK)
+ {
+ win_skip("ID2D1Image is not supported.\n");
+ return;
+ }
+
+ if (0) /* Crashes on Windows 7+ */
+ hr = ID2D1DeviceContext_CreateImageBrush(device_context, NULL, NULL, NULL, &brush);
+
+ if (0) /* Crashes on Windows 7+ */
+ hr = ID2D1DeviceContext_CreateImageBrush(device_context, image, NULL, NULL, &brush);
+
+ set_rect(&image_brush_desc.sourceRectangle, 0.0f, 0.0f, 4.0f, 4.0f);
+ image_brush_desc.extendModeX = D2D1_EXTEND_MODE_CLAMP;
+ image_brush_desc.extendModeY = D2D1_EXTEND_MODE_CLAMP;
+ image_brush_desc.interpolationMode = D2D1_INTERPOLATION_MODE_LINEAR;
+
+ brush_desc.opacity = 1.0f;
+ set_matrix_identity(&brush_desc.transform);
+
+ if (0) /* Crashes on Windows 7+ */
+ hr = ID2D1DeviceContext_CreateImageBrush(device_context, image, NULL, &brush_desc, &brush);
+
+ hr = ID2D1DeviceContext_CreateImageBrush(device_context, image, &image_brush_desc, NULL, &brush);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ID2D1ImageBrush_Release(brush);
+
+ hr = ID2D1DeviceContext_CreateImageBrush(device_context, image, &image_brush_desc, &brush_desc, &brush);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+ ID2D1ImageBrush_GetImage(brush, &tmp_image);
+ ok(tmp_image == image, "Got unexpected image %p, expected %p.\n", tmp_image, image);
+ ID2D1Image_Release(tmp_image);
+
+ ID2D1ImageBrush_Release(brush);
+
+ ID2D1Image_Release(image);
+ refcount = ID2D1Bitmap_Release(bitmap);
+ ok(!refcount, "Bitmap has %lu references left.\n", refcount);
+
+ ID2D1DeviceContext_Release(device_context);
+ release_test_context(&ctx);
+}
+
static void test_linear_brush(BOOL d3d11)
{
D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES gradient_properties;
@@ -10919,6 +11003,7 @@ START_TEST(d2d1)
queue_test(test_state_block);
queue_test(test_color_brush);
queue_test(test_bitmap_brush);
+ queue_test(test_image_brush);
queue_test(test_linear_brush);
queue_test(test_radial_brush);
queue_test(test_path_geometry);
--
2.35.3
More information about the wine-devel
mailing list