[PATCH 2/5] d2d1/tests: Test d2d_device_context_SetTarget() with bitmaps of D2D1_ALPHA_MODE_IGNORE.
Zhiyi Zhang
zzhang at codeweavers.com
Fri Mar 11 00:31:47 CST 2022
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
dlls/d2d1/tests/d2d1.c | 50 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 3ade9634069..7c54f365e06 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -4341,18 +4341,22 @@ static void test_bitmap_formats(BOOL d3d11)
static void test_alpha_mode(BOOL d3d11)
{
D2D1_RENDER_TARGET_PROPERTIES rt_desc;
+ D2D1_BITMAP_PROPERTIES1 bitmap_desc1;
D2D1_BITMAP_PROPERTIES bitmap_desc;
ID2D1SolidColorBrush *color_brush;
ID2D1BitmapBrush *bitmap_brush;
struct d2d1_test_context ctx;
+ ID2D1DeviceContext *context;
+ ID2D1Bitmap1 *bitmap1;
ID2D1RenderTarget *rt;
+ IDXGISurface *surface;
ID2D1Bitmap *bitmap;
D2D1_COLOR_F color;
+ BOOL match, match2;
D2D1_RECT_F rect;
D2D1_SIZE_U size;
ULONG refcount;
HRESULT hr;
- BOOL match;
static const DWORD bitmap_data[] =
{
@@ -4546,8 +4550,50 @@ static void test_alpha_mode(BOOL d3d11)
refcount = ID2D1Bitmap_Release(bitmap);
ok(refcount == 1, "Bitmap has %lu references left.\n", refcount);
- ID2D1SolidColorBrush_Release(color_brush);
ID2D1BitmapBrush_Release(bitmap_brush);
+
+ hr = ID2D1RenderTarget_QueryInterface(rt, &IID_ID2D1DeviceContext, (void **)&context);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+ set_size_u(&size, 4, 4);
+ memset(&bitmap_desc1, 0, sizeof(bitmap_desc1));
+ bitmap_desc1.dpiX = 96.0f;
+ bitmap_desc1.dpiY = 96.0f;
+ bitmap_desc1.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM;
+ bitmap_desc1.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE;
+ bitmap_desc1.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW;
+ hr = ID2D1DeviceContext_CreateBitmap(context, size, bitmap_data, 4 * sizeof(*bitmap_data),
+ &bitmap_desc1, &bitmap1);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+ ID2D1DeviceContext_BeginDraw(context);
+ ID2D1DeviceContext_SetTarget(context, (ID2D1Image *)bitmap1);
+ set_rect(&rect, 0.0f, 2.0f, 1.0f, 2.0f);
+ ID2D1SolidColorBrush_SetOpacity(color_brush, 1.0f);
+ ID2D1DeviceContext_FillRectangle(context, &rect, (ID2D1Brush *)color_brush);
+ set_rect(&rect, 1.0f, 2.0f, 3.0f, 3.0f);
+ ID2D1SolidColorBrush_SetOpacity(color_brush, 0.75f);
+ ID2D1DeviceContext_FillRectangle(context, &rect, (ID2D1Brush *)color_brush);
+ set_rect(&rect, 3.0f, 2.0f, 3.0f, 3.0f);
+ ID2D1SolidColorBrush_SetOpacity(color_brush, 0.25f);
+ ID2D1DeviceContext_FillRectangle(context, &rect, (ID2D1Brush *)color_brush);
+ hr = ID2D1DeviceContext_EndDraw(context, NULL, NULL);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+ surface = ctx.surface;
+ hr = ID2D1Bitmap1_GetSurface(bitmap1, &ctx.surface);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ match = compare_surface(&ctx, "e7ee77e89745fa5d195fd78bd398738330cfcde8");
+ match2 = compare_surface(&ctx, "4855c7c082c8ede364cf6e2dcde83f95b88aecbe");
+ todo_wine
+ ok(match || broken(match2) /* Win7 TestBots */, "Surface does not match.\n");
+ IDXGISurface_Release(ctx.surface);
+ ctx.surface = surface;
+ ID2D1DeviceContext_SetTarget(context, NULL);
+
+ ID2D1Bitmap1_Release(bitmap1);
+ ID2D1DeviceContext_Release(context);
+ ID2D1SolidColorBrush_Release(color_brush);
ID2D1RenderTarget_Release(rt);
release_test_context(&ctx);
}
--
2.32.0
More information about the wine-devel
mailing list