Commit c9b68daf authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d2d1: Implement IsSupported() for HWND target.

parent 4150d728
......@@ -264,6 +264,8 @@ struct d2d_hwnd_render_target
IDXGISwapChain *swapchain;
UINT sync_interval;
HWND hwnd;
D2D1_RENDER_TARGET_PROPERTIES desc;
};
HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target, ID2D1Factory1 *factory,
......
......@@ -652,10 +652,32 @@ static BOOL STDMETHODCALLTYPE d2d_hwnd_render_target_IsSupported(ID2D1HwndRender
const D2D1_RENDER_TARGET_PROPERTIES *desc)
{
struct d2d_hwnd_render_target *render_target = impl_from_ID2D1HwndRenderTarget(iface);
const D2D1_RENDER_TARGET_PROPERTIES *target_desc = &render_target->desc;
D2D1_PIXEL_FORMAT pixel_format;
TRACE("iface %p, desc %p.\n", iface, desc);
return ID2D1RenderTarget_IsSupported(render_target->dxgi_target, desc);
if (desc->type != D2D1_RENDER_TARGET_TYPE_DEFAULT
&& target_desc->type != desc->type)
{
return FALSE;
}
pixel_format = ID2D1RenderTarget_GetPixelFormat(render_target->dxgi_target);
if (desc->pixelFormat.format != DXGI_FORMAT_UNKNOWN
&& pixel_format.format != desc->pixelFormat.format)
{
return FALSE;
}
if (desc->pixelFormat.alphaMode != D2D1_ALPHA_MODE_UNKNOWN
&& pixel_format.alphaMode != desc->pixelFormat.alphaMode)
{
return FALSE;
}
return (target_desc->usage & desc->usage) == desc->usage;
}
static D2D1_WINDOW_STATE STDMETHODCALLTYPE d2d_hwnd_render_target_CheckWindowState(ID2D1HwndRenderTarget *iface)
......@@ -840,6 +862,11 @@ 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;
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)
render_target->desc.type = D2D1_RENDER_TARGET_TYPE_HARDWARE;
swapchain_desc.BufferDesc.Width = hwnd_rt_desc->pixelSize.width;
swapchain_desc.BufferDesc.Height = hwnd_rt_desc->pixelSize.height;
swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
......
......@@ -13429,7 +13429,6 @@ static void test_hwnd_target_is_supported(BOOL d3d11)
hr = ID2D1Factory_CreateHwndRenderTarget(ctx.factory, &template_desc, &hwnd_rt_desc, &rt);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
supported = ID2D1HwndRenderTarget_IsSupported(rt, &template_desc);
todo_wine
ok(supported, "Expected supported.\n");
ID2D1HwndRenderTarget_Release(rt);
......@@ -13476,7 +13475,6 @@ static void test_hwnd_target_is_supported(BOOL d3d11)
ok(pixel_format.format == DXGI_FORMAT_R8G8B8A8_UNORM, "Got unexpected format %#x.\n", pixel_format.format);
ok(pixel_format.alphaMode == D2D1_ALPHA_MODE_PREMULTIPLIED, "Got unexpected alpha %u.\n", pixel_format.alphaMode);
supported = ID2D1HwndRenderTarget_IsSupported(rt, &test_desc);
todo_wine
ok(supported, "Expected supported.\n");
ID2D1Bitmap1_Release(bitmap);
......@@ -13497,7 +13495,6 @@ static void test_hwnd_target_is_supported(BOOL d3d11)
test_desc = template_desc;
test_desc.type = D2D1_RENDER_TARGET_TYPE_DEFAULT;
supported = ID2D1HwndRenderTarget_IsSupported(rt, &test_desc);
todo_wine
ok(supported, "Unexpected return value %d.\n", supported);
}
else
......@@ -13514,7 +13511,6 @@ static void test_hwnd_target_is_supported(BOOL d3d11)
supported = ID2D1HwndRenderTarget_IsSupported(rt, &test_desc);
expected = target_types[j] == D2D1_RENDER_TARGET_TYPE_DEFAULT
|| target_types[i] == target_types[j];
todo_wine_if(expected)
ok(supported == expected, "Unexpected return value %d.\n", supported);
winetest_pop_context();
......@@ -13556,7 +13552,6 @@ static void test_hwnd_target_is_supported(BOOL d3d11)
alpha_mode_supported = pixel_formats[j].alphaMode == D2D1_ALPHA_MODE_UNKNOWN
|| pixel_formats[j].alphaMode == desc.pixelFormat.alphaMode;
expected = format_supported && alpha_mode_supported;
todo_wine_if(expected)
ok(supported == expected, "Unexpected return value.\n");
winetest_pop_context();
......@@ -13589,7 +13584,6 @@ static void test_hwnd_target_is_supported(BOOL d3d11)
desc.usage = usages[j];
supported = ID2D1HwndRenderTarget_IsSupported(rt, &desc);
expected = (usages[i] & usages[j]) == usages[j];
todo_wine_if(expected)
ok(supported == expected, "Unexpected result %d.\n", supported);
winetest_pop_context();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment