From ae43a87d017ca28a7f246e5d755a50c73a4024df Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sun, 21 May 2023 15:58:40 +0200 Subject: [PATCH] d2d1: Reject D2D1_ALPHA_MODE_STRAIGHT alpha mode for HWND targets. --- dlls/d2d1/hwnd_render_target.c | 7 +++++++ dlls/d2d1/tests/d2d1.c | 5 +---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dlls/d2d1/hwnd_render_target.c b/dlls/d2d1/hwnd_render_target.c index 325eb941782..a62f31b909d 100644 --- a/dlls/d2d1/hwnd_render_target.c +++ b/dlls/d2d1/hwnd_render_target.c @@ -862,6 +862,13 @@ HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target if (dxgi_rt_desc.pixelFormat.alphaMode == D2D1_ALPHA_MODE_UNKNOWN) dxgi_rt_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE; + if (dxgi_rt_desc.pixelFormat.alphaMode == D2D1_ALPHA_MODE_STRAIGHT) + { + IDXGIFactory_Release(dxgi_factory); + WARN("Alpha mode %u is not supported.\n", dxgi_rt_desc.pixelFormat.alphaMode); + return D2DERR_UNSUPPORTED_PIXEL_FORMAT; + } + render_target->desc = dxgi_rt_desc; /* FIXME: should be resolved to either HW or SW type. */ if (render_target->desc.type == D2D1_RENDER_TARGET_TYPE_DEFAULT) diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index f0b0da732df..1607bacd2bc 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -6214,10 +6214,7 @@ static void test_hwnd_target(BOOL d3d11) hr = ID2D1Factory_CreateHwndRenderTarget(ctx.factory, &desc, &hwnd_rt_desc, &rt); if (format_tests[i].expected_failure) { - todo_wine - ok(FAILED(hr), "Got unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - ID2D1HwndRenderTarget_Release(rt); + ok(hr == D2DERR_UNSUPPORTED_PIXEL_FORMAT, "Got unexpected hr %#lx.\n", hr); winetest_pop_context(); continue; }