From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/dc_render_target.c | 4 +++- dlls/d2d1/tests/d2d1.c | 45 +++++++++++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/dlls/d2d1/dc_render_target.c b/dlls/d2d1/dc_render_target.c index 01e1c348746..30eafe361d1 100644 --- a/dlls/d2d1/dc_render_target.c +++ b/dlls/d2d1/dc_render_target.c @@ -689,11 +689,13 @@ static HRESULT STDMETHODCALLTYPE d2d_dc_render_target_BindDC(ID2D1DCRenderTarget ID2D1DeviceContext *context; D2D1_SIZE_U bitmap_size; ID2D1Bitmap *bitmap; + DWORD obj_type; HRESULT hr;
TRACE("iface %p, hdc %p, rect %s.\n", iface, hdc, wine_dbgstr_rect(rect));
- if (!hdc) + obj_type = GetObjectType(hdc); + if (obj_type != OBJ_DC && obj_type != OBJ_ENHMETADC && obj_type != OBJ_MEMDC) return E_INVALIDARG;
/* Switch dxgi target to new surface. */ diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 08c7bc05224..3bfc8973c31 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -5825,15 +5825,18 @@ static void test_dc_target(BOOL d3d11) ID2D1Factory *factory; FLOAT dpi_x, dpi_y; D2D1_COLOR_F color; + HENHMETAFILE hemf; D2D1_SIZE_U sizeu; D2D1_SIZE_F size; D2D1_TAG t1, t2; unsigned int i; HDC hdc, hdc2; + HMETAFILE hmf; D2D_RECT_F r; COLORREF clr; HRESULT hr; RECT rect; + HWND hwnd;
if (!init_test_context(&ctx, d3d11)) return; @@ -5997,7 +6000,7 @@ static void test_dc_target(BOOL d3d11)
/* Invalid DC. */ hr = ID2D1DCRenderTarget_BindDC(rt, (HDC)0xdeadbeef, &rect); - todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
ID2D1DCRenderTarget_BeginDraw(rt);
@@ -6008,7 +6011,7 @@ static void test_dc_target(BOOL d3d11) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
clr = GetPixel(hdc2, 0, 0); - todo_wine ok(clr == RGB(255, 0, 0), "Got unexpected colour 0x%08lx.\n", clr); + ok(clr == RGB(255, 0, 0), "Got unexpected colour 0x%08lx.\n", clr);
hr = ID2D1DCRenderTarget_BindDC(rt, NULL, &rect); ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); @@ -6022,10 +6025,46 @@ static void test_dc_target(BOOL d3d11) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
clr = GetPixel(hdc2, 0, 0); - todo_wine ok(clr == RGB(0, 0, 255), "Got unexpected colour 0x%08lx.\n", clr); + ok(clr == RGB(0, 0, 255), "Got unexpected colour 0x%08lx.\n", clr);
DeleteDC(hdc); DeleteDC(hdc2); + + /* Metafile context. */ + hdc = CreateMetaFileA(NULL); + ok(!!hdc, "Failed to create a device context.\n"); + + hr = ID2D1DCRenderTarget_BindDC(rt, hdc, &rect); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); + + hmf = CloseMetaFile(hdc); + ok(!!hmf, "Failed to close a metafile, error %ld.\n", GetLastError()); + DeleteMetaFile(hmf); + + /* Enhanced metafile context. */ + hdc = CreateEnhMetaFileA(NULL, NULL, NULL, NULL); + ok(!!hdc, "Failed to create a device context.\n"); + + hr = ID2D1DCRenderTarget_BindDC(rt, hdc, &rect); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hemf = CloseEnhMetaFile(hdc); + ok(!!hemf, "Failed to close a metafile, error %ld.\n", GetLastError()); + DeleteEnhMetaFile(hemf); + + /* Window context. */ + hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 100, 100, 0, 0, 0, NULL); + ok(!!hwnd, "Failed to create a test window.\n"); + + hdc = GetDC(hwnd); + ok(!!hdc, "Failed to get a context.\n"); + + hr = ID2D1DCRenderTarget_BindDC(rt, hdc, &rect); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + ReleaseDC(hwnd, hdc); + DestroyWindow(hwnd); + ID2D1DCRenderTarget_Release(rt); ID2D1Factory_Release(factory); }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=125390
Your paranoid android.
=== debian11 (32 bit report) ===
d3d9: device.c:5893: Test failed: Failed to create a D3D object.