d2d1/tests: Test that target properties are kept during BindDC().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-09-07 17:33:50 +03:00 committed by Alexandre Julliard
parent 9bc3e9614f
commit ccc6a576d6
1 changed files with 38 additions and 1 deletions

View File

@ -2654,18 +2654,23 @@ static void test_dc_target(void)
{ DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_UNKNOWN },
{ DXGI_FORMAT_R8G8B8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED },
};
D2D1_TEXT_ANTIALIAS_MODE text_aa_mode;
D2D1_RENDER_TARGET_PROPERTIES desc;
D2D1_MATRIX_3X2_F matrix, matrix2;
D2D1_ANTIALIAS_MODE aa_mode;
ID2D1SolidColorBrush *brush;
ID2D1DCRenderTarget *rt;
ID2D1Factory *factory;
FLOAT dpi_x, dpi_y;
D2D1_COLOR_F color;
D2D1_SIZE_F size;
D2D1_TAG t1, t2;
unsigned int i;
HDC hdc, hdc2;
D2D_RECT_F r;
COLORREF clr;
HRESULT hr;
RECT rect;
D2D_RECT_F r;
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, NULL, (void **)&factory);
ok(SUCCEEDED(hr), "Failed to create factory, hr %#x.\n", hr);
@ -2716,6 +2721,14 @@ if (SUCCEEDED(hr))
hr = ID2D1Factory_CreateDCRenderTarget(factory, &desc, &rt);
ok(SUCCEEDED(hr), "Failed to create target, hr %#x.\n", hr);
aa_mode = ID2D1DCRenderTarget_GetAntialiasMode(rt);
ok(aa_mode == D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, "Got wrong default aa mode %d.\n", aa_mode);
text_aa_mode = ID2D1DCRenderTarget_GetTextAntialiasMode(rt);
ok(text_aa_mode == D2D1_TEXT_ANTIALIAS_MODE_DEFAULT, "Got wrong default text aa mode %d.\n", text_aa_mode);
ID2D1DCRenderTarget_GetDpi(rt, &dpi_x, &dpi_y);
ok(dpi_x == 96.0f && dpi_y == 96.0f, "Got dpi_x %f, dpi_y %f.\n", dpi_x, dpi_y);
hdc = CreateCompatibleDC(NULL);
ok(hdc != NULL, "Failed to create an HDC.\n");
@ -2725,9 +2738,33 @@ if (SUCCEEDED(hr))
hr = ID2D1DCRenderTarget_BindDC(rt, NULL, &rect);
ok(hr == E_INVALIDARG, "BindDC() returned %#x.\n", hr);
/* Target properties are retained during BindDC() */
ID2D1DCRenderTarget_SetTags(rt, 1, 2);
ID2D1DCRenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_ALIASED);
ID2D1DCRenderTarget_SetTextAntialiasMode(rt, D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE);
set_matrix_identity(&matrix);
translate_matrix(&matrix, 200.0f, 600.0f);
ID2D1DCRenderTarget_SetTransform(rt, &matrix);
hr = ID2D1DCRenderTarget_BindDC(rt, hdc, &rect);
ok(hr == S_OK, "BindDC() returned %#x.\n", hr);
ID2D1DCRenderTarget_GetTags(rt, &t1, &t2);
ok(t1 == 1 && t2 == 2, "Got wrong tags.\n");
aa_mode = ID2D1DCRenderTarget_GetAntialiasMode(rt);
ok(aa_mode == D2D1_ANTIALIAS_MODE_ALIASED, "Got wrong aa mode %d.\n", aa_mode);
text_aa_mode = ID2D1DCRenderTarget_GetTextAntialiasMode(rt);
ok(text_aa_mode == D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE, "Got wrong text aa mode %d.\n", text_aa_mode);
ID2D1DCRenderTarget_GetTransform(rt, &matrix2);
ok(!memcmp(&matrix, &matrix2, sizeof(matrix)), "Got wrong target transform.\n");
set_matrix_identity(&matrix);
ID2D1DCRenderTarget_SetTransform(rt, &matrix);
/* target size comes from specified dimensions, not from selected bitmap size */
size = ID2D1DCRenderTarget_GetSize(rt);
ok(size.width == 32.0f, "got width %.08e.\n", size.width);