mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-06 14:24:11 +00:00
d2d1: Test device context type in BindDC().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
ffbe1e6229
commit
e6069c2530
|
@ -689,11 +689,13 @@ static HRESULT STDMETHODCALLTYPE d2d_dc_render_target_BindDC(ID2D1DCRenderTarget
|
||||||
ID2D1DeviceContext *context;
|
ID2D1DeviceContext *context;
|
||||||
D2D1_SIZE_U bitmap_size;
|
D2D1_SIZE_U bitmap_size;
|
||||||
ID2D1Bitmap *bitmap;
|
ID2D1Bitmap *bitmap;
|
||||||
|
DWORD obj_type;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("iface %p, hdc %p, rect %s.\n", iface, hdc, wine_dbgstr_rect(rect));
|
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;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
/* Switch dxgi target to new surface. */
|
/* Switch dxgi target to new surface. */
|
||||||
|
|
|
@ -5825,15 +5825,18 @@ static void test_dc_target(BOOL d3d11)
|
||||||
ID2D1Factory *factory;
|
ID2D1Factory *factory;
|
||||||
FLOAT dpi_x, dpi_y;
|
FLOAT dpi_x, dpi_y;
|
||||||
D2D1_COLOR_F color;
|
D2D1_COLOR_F color;
|
||||||
|
HENHMETAFILE hemf;
|
||||||
D2D1_SIZE_U sizeu;
|
D2D1_SIZE_U sizeu;
|
||||||
D2D1_SIZE_F size;
|
D2D1_SIZE_F size;
|
||||||
D2D1_TAG t1, t2;
|
D2D1_TAG t1, t2;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
HDC hdc, hdc2;
|
HDC hdc, hdc2;
|
||||||
|
HMETAFILE hmf;
|
||||||
D2D_RECT_F r;
|
D2D_RECT_F r;
|
||||||
COLORREF clr;
|
COLORREF clr;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
HWND hwnd;
|
||||||
|
|
||||||
if (!init_test_context(&ctx, d3d11))
|
if (!init_test_context(&ctx, d3d11))
|
||||||
return;
|
return;
|
||||||
|
@ -5997,7 +6000,7 @@ static void test_dc_target(BOOL d3d11)
|
||||||
|
|
||||||
/* Invalid DC. */
|
/* Invalid DC. */
|
||||||
hr = ID2D1DCRenderTarget_BindDC(rt, (HDC)0xdeadbeef, &rect);
|
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);
|
ID2D1DCRenderTarget_BeginDraw(rt);
|
||||||
|
|
||||||
|
@ -6008,7 +6011,7 @@ static void test_dc_target(BOOL d3d11)
|
||||||
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
||||||
|
|
||||||
clr = GetPixel(hdc2, 0, 0);
|
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);
|
hr = ID2D1DCRenderTarget_BindDC(rt, NULL, &rect);
|
||||||
ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
|
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);
|
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
||||||
|
|
||||||
clr = GetPixel(hdc2, 0, 0);
|
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(hdc);
|
||||||
DeleteDC(hdc2);
|
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);
|
ID2D1DCRenderTarget_Release(rt);
|
||||||
ID2D1Factory_Release(factory);
|
ID2D1Factory_Release(factory);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue