[PATCH 1/5] d2d1/tests: Test output bounds for D2D1Grayscale.

Ziqing Hui zhui at codeweavers.com
Wed Apr 20 03:04:25 CDT 2022


Signed-off-by: Ziqing Hui <zhui at 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);
 
-- 
2.25.1




More information about the wine-devel mailing list