mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-15 05:57:27 +00:00
d2d1: Improve GetDC()/ReleaseDC() handling on render targets.
This commit is contained in:
parent
981db8313f
commit
6526de5c5a
|
@ -183,6 +183,7 @@ struct d2d_device_context
|
|||
struct d2d_bitmap *bitmap;
|
||||
struct d2d_command_list *command_list;
|
||||
};
|
||||
HDC hdc;
|
||||
} target;
|
||||
struct d2d_shape_resources shape_resources[D2D_SHAPE_TYPE_COUNT];
|
||||
ID3D11Buffer *vs_cb;
|
||||
|
|
|
@ -3097,7 +3097,7 @@ static ULONG STDMETHODCALLTYPE d2d_gdi_interop_render_target_Release(ID2D1GdiInt
|
|||
return IUnknown_Release(render_target->outer_unknown);
|
||||
}
|
||||
|
||||
static HRESULT d2d_device_context_get_surface(struct d2d_device_context *context, IDXGISurface1 **surface)
|
||||
static HRESULT d2d_gdi_interop_get_surface(struct d2d_device_context *context, IDXGISurface1 **surface)
|
||||
{
|
||||
ID3D11Resource *resource;
|
||||
HRESULT hr;
|
||||
|
@ -3108,6 +3108,9 @@ static HRESULT d2d_device_context_get_surface(struct d2d_device_context *context
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
if (!(context->target.bitmap->options & D2D1_BITMAP_OPTIONS_GDI_COMPATIBLE))
|
||||
return D2DERR_TARGET_NOT_GDI_COMPATIBLE;
|
||||
|
||||
ID3D11RenderTargetView_GetResource(context->target.bitmap->rtv, &resource);
|
||||
hr = ID3D11Resource_QueryInterface(resource, &IID_IDXGISurface1, (void **)surface);
|
||||
ID3D11Resource_Release(resource);
|
||||
|
@ -3130,12 +3133,20 @@ static HRESULT STDMETHODCALLTYPE d2d_gdi_interop_render_target_GetDC(ID2D1GdiInt
|
|||
|
||||
TRACE("iface %p, mode %d, dc %p.\n", iface, mode, dc);
|
||||
|
||||
if (FAILED(hr = d2d_device_context_get_surface(render_target, &surface)))
|
||||
*dc = NULL;
|
||||
|
||||
if (render_target->target.hdc)
|
||||
return D2DERR_WRONG_STATE;
|
||||
|
||||
if (FAILED(hr = d2d_gdi_interop_get_surface(render_target, &surface)))
|
||||
return hr;
|
||||
|
||||
hr = IDXGISurface1_GetDC(surface, mode != D2D1_DC_INITIALIZE_MODE_COPY, dc);
|
||||
hr = IDXGISurface1_GetDC(surface, mode != D2D1_DC_INITIALIZE_MODE_COPY, &render_target->target.hdc);
|
||||
IDXGISurface1_Release(surface);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
*dc = render_target->target.hdc;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -3149,9 +3160,13 @@ static HRESULT STDMETHODCALLTYPE d2d_gdi_interop_render_target_ReleaseDC(ID2D1Gd
|
|||
|
||||
TRACE("iface %p, update rect %s.\n", iface, wine_dbgstr_rect(update));
|
||||
|
||||
if (FAILED(hr = d2d_device_context_get_surface(render_target, &surface)))
|
||||
if (!render_target->target.hdc)
|
||||
return D2DERR_WRONG_STATE;
|
||||
|
||||
if (FAILED(hr = d2d_gdi_interop_get_surface(render_target, &surface)))
|
||||
return hr;
|
||||
|
||||
render_target->target.hdc = NULL;
|
||||
if (update)
|
||||
update_rect = *update;
|
||||
hr = IDXGISurface1_ReleaseDC(surface, update ? &update_rect : NULL);
|
||||
|
|
|
@ -6166,7 +6166,7 @@ static void test_dc_target_gdi_interop(BOOL d3d11)
|
|||
hr = ID2D1GdiInteropRenderTarget_GetDC(interop, D2D1_DC_INITIALIZE_MODE_COPY, &hdc);
|
||||
todo_wine
|
||||
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#lx.\n", hr);
|
||||
todo_wine ok(!hdc, "Got unexpected DC %p.\n", hdc);
|
||||
ok(!hdc, "Got unexpected DC %p.\n", hdc);
|
||||
hr = ID2D1DCRenderTarget_EndDraw(rt, NULL, NULL);
|
||||
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#lx.\n", hr);
|
||||
|
||||
|
@ -6335,9 +6335,8 @@ static void test_hwnd_target_gdi_interop(BOOL d3d11)
|
|||
ID2D1HwndRenderTarget_BeginDraw(rt);
|
||||
dc = (void *)0xdeadbeef;
|
||||
hr = ID2D1GdiInteropRenderTarget_GetDC(interop, D2D1_DC_INITIALIZE_MODE_COPY, &dc);
|
||||
todo_wine
|
||||
ok(hr == D2DERR_TARGET_NOT_GDI_COMPATIBLE, "Got unexpected hr %#lx.\n", hr);
|
||||
todo_wine ok(!dc, "Got unexpected DC %p.\n", dc);
|
||||
ok(!dc, "Got unexpected DC %p.\n", dc);
|
||||
hr = ID2D1HwndRenderTarget_EndDraw(rt, NULL, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
||||
ID2D1GdiInteropRenderTarget_Release(interop);
|
||||
|
@ -6441,9 +6440,10 @@ static void test_dxgi_surface_target_gdi_interop(BOOL d3d11)
|
|||
ID2D1RenderTarget_BeginDraw(rt);
|
||||
dc = (void *)0xdeadbeef;
|
||||
hr = ID2D1GdiInteropRenderTarget_GetDC(interop, D2D1_DC_INITIALIZE_MODE_COPY, &dc);
|
||||
todo_wine
|
||||
ok(hr == D2DERR_TARGET_NOT_GDI_COMPATIBLE, "Got unexpected hr %#lx.\n", hr);
|
||||
todo_wine ok(!dc, "Got unexpected DC %p.\n", dc);
|
||||
ok(!dc, "Got unexpected DC %p.\n", dc);
|
||||
hr = ID2D1GdiInteropRenderTarget_ReleaseDC(interop, NULL);
|
||||
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#lx.\n", hr);
|
||||
hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
||||
ID2D1GdiInteropRenderTarget_Release(interop);
|
||||
|
@ -6481,6 +6481,9 @@ static void test_dxgi_surface_target_gdi_interop(BOOL d3d11)
|
|||
hr = ID2D1GdiInteropRenderTarget_GetDC(interop, D2D1_DC_INITIALIZE_MODE_COPY, &dc);
|
||||
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
||||
ok(!!dc, "Got unexpected DC %p.\n", dc);
|
||||
hr = ID2D1GdiInteropRenderTarget_GetDC(interop, D2D1_DC_INITIALIZE_MODE_COPY, &dc);
|
||||
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#lx.\n", hr);
|
||||
ok(!dc, "Got unexpected DC %p.\n", dc);
|
||||
hr = ID2D1GdiInteropRenderTarget_ReleaseDC(interop, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
||||
hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL);
|
||||
|
@ -6499,8 +6502,10 @@ static void test_dxgi_surface_target_gdi_interop(BOOL d3d11)
|
|||
ID2D1RenderTarget_BeginDraw(rt);
|
||||
dc = (void *)0xdeadbeef;
|
||||
hr = ID2D1GdiInteropRenderTarget_GetDC(interop, D2D1_DC_INITIALIZE_MODE_COPY, &dc);
|
||||
todo_wine ok(hr == D2DERR_TARGET_NOT_GDI_COMPATIBLE, "Got unexpected hr %#lx.\n", hr);
|
||||
todo_wine ok(!dc, "Got unexpected DC %p.\n", dc);
|
||||
ok(hr == D2DERR_TARGET_NOT_GDI_COMPATIBLE, "Got unexpected hr %#lx.\n", hr);
|
||||
ok(!dc, "Got unexpected DC %p.\n", dc);
|
||||
hr = ID2D1GdiInteropRenderTarget_ReleaseDC(interop, NULL);
|
||||
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#lx.\n", hr);
|
||||
hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
||||
ID2D1GdiInteropRenderTarget_Release(interop);
|
||||
|
@ -8781,9 +8786,8 @@ static void test_wic_gdi_interop(BOOL d3d11)
|
|||
ID2D1RenderTarget_BeginDraw(rt);
|
||||
dc = (void *)0xdeadbeef;
|
||||
hr = ID2D1GdiInteropRenderTarget_GetDC(interop, D2D1_DC_INITIALIZE_MODE_COPY, &dc);
|
||||
todo_wine
|
||||
ok(hr == D2DERR_TARGET_NOT_GDI_COMPATIBLE, "Got unexpected hr %#lx.\n", hr);
|
||||
todo_wine ok(!dc, "Got unexpected DC %p.\n", dc);
|
||||
ok(!dc, "Got unexpected DC %p.\n", dc);
|
||||
ID2D1GdiInteropRenderTarget_Release(interop);
|
||||
hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
||||
|
|
Loading…
Reference in a new issue