Commit fd99c33e authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

Initialize a bunch of dc values to their default before enumerating an

enhmetafile. Add tests for these and for some values that don't get reset.
parent 793f9a51
......@@ -2147,7 +2147,7 @@ BOOL WINAPI EnumEnhMetaFile(
enum_emh_data *info;
SIZE vp_size, win_size;
POINT vp_org, win_org;
INT mapMode = MM_TEXT;
INT mapMode = MM_TEXT, old_align = 0, old_rop2 = 0, old_arcdir = 0, old_polyfill = 0, old_stretchblt = 0;
COLORREF old_text_color = 0, old_bk_color = 0;
if(!lpRect && hdc)
......@@ -2201,6 +2201,11 @@ BOOL WINAPI EnumEnhMetaFile(
old_text_color = SetTextColor(hdc, RGB(0,0,0));
old_bk_color = SetBkColor(hdc, RGB(0xff, 0xff, 0xff));
old_align = SetTextAlign(hdc, 0);
old_rop2 = SetROP2(hdc, R2_COPYPEN);
old_arcdir = SetArcDirection(hdc, AD_COUNTERCLOCKWISE);
old_polyfill = SetPolyFillMode(hdc, ALTERNATE);
old_stretchblt = SetStretchBltMode(hdc, BLACKONWHITE);
}
info->mode = MM_TEXT;
......@@ -2280,6 +2285,11 @@ BOOL WINAPI EnumEnhMetaFile(
if (hdc)
{
SetStretchBltMode(hdc, old_stretchblt);
SetPolyFillMode(hdc, old_polyfill);
SetArcDirection(hdc, old_arcdir);
SetROP2(hdc, old_rop2);
SetTextAlign(hdc, old_align);
SetBkColor(hdc, old_bk_color);
SetTextColor(hdc, old_text_color);
......
......@@ -55,6 +55,18 @@ static int CALLBACK emf_enum_proc(HDC hdc, HANDLETABLE *handle_table,
switch (emr->iType)
{
case EMR_HEADER:
ok(GetTextAlign(hdc) == 0, "text align %08x\n", GetTextAlign(hdc));
ok(GetBkColor(hdc) == RGB(0xff, 0xff, 0xff), "bk color %08lx\n", GetBkColor(hdc));
ok(GetTextColor(hdc) == RGB(0x0, 0x0, 0x0), "text color %08lx\n", GetTextColor(hdc));
ok(GetROP2(hdc) == R2_COPYPEN, "rop %d\n", GetROP2(hdc));
ok(GetArcDirection(hdc) == AD_COUNTERCLOCKWISE, "arc dir %d\n", GetArcDirection(hdc));
ok(GetPolyFillMode(hdc) == ALTERNATE, "poly fill %d\n", GetPolyFillMode(hdc));
ok(GetStretchBltMode(hdc) == BLACKONWHITE, "stretchblt mode %d\n", GetStretchBltMode(hdc));
/* GetBkMode, GetRelAbs do not get reset to the default value */
ok(GetBkMode(hdc) == OPAQUE, "bk mode %d\n", GetBkMode(hdc));
ok(GetRelAbs(hdc, 0) == RELATIVE, "relabs %d\n", GetRelAbs(hdc, 0));
n_record = 0;
break;
......@@ -189,9 +201,29 @@ static void test_ExtTextOut(void)
ret = PlayEnhMetaFile(hdcDisplay, hMetafile, &rc);
ok( ret, "PlayEnhMetaFile error %ld\n", GetLastError());
SetTextAlign(hdcDisplay, TA_UPDATECP | TA_CENTER | TA_BASELINE | TA_RTLREADING );
SetBkColor(hdcDisplay, RGB(0xff, 0, 0));
SetTextColor(hdcDisplay, RGB(0, 0xff, 0));
SetROP2(hdcDisplay, R2_NOT);
SetArcDirection(hdcDisplay, AD_CLOCKWISE);
SetPolyFillMode(hdcDisplay, WINDING);
SetStretchBltMode(hdcDisplay, HALFTONE);
SetRelAbs(hdcDisplay, RELATIVE);
SetBkMode(hdcDisplay, OPAQUE);
ret = EnumEnhMetaFile(hdcDisplay, hMetafile, emf_enum_proc, dx, &rc);
ok( ret, "EnumEnhMetaFile error %ld\n", GetLastError());
ok( GetTextAlign(hdcDisplay) == (TA_UPDATECP | TA_CENTER | TA_BASELINE | TA_RTLREADING),
"text align %08x\n", GetTextAlign(hdcDisplay));
ok( GetBkColor(hdcDisplay) == RGB(0xff, 0, 0), "bk color %08lx\n", GetBkColor(hdcDisplay));
ok( GetTextColor(hdcDisplay) == RGB(0, 0xff, 0), "text color %08lx\n", GetTextColor(hdcDisplay));
ok( GetROP2(hdcDisplay) == R2_NOT, "rop2 %d\n", GetROP2(hdcDisplay));
ok( GetArcDirection(hdcDisplay) == AD_CLOCKWISE, "arc dir %d\n", GetArcDirection(hdcDisplay));
ok( GetPolyFillMode(hdcDisplay) == WINDING, "poly fill %d\n", GetPolyFillMode(hdcDisplay));
ok( GetStretchBltMode(hdcDisplay) == HALFTONE, "stretchblt mode %d\n", GetStretchBltMode(hdcDisplay));
ok(emr_processed, "EnumEnhMetaFile couldn't find EMR_EXTTEXTOUTA or EMR_EXTTEXTOUTW record\n");
ok(!EnumEnhMetaFile(hdcDisplay, hMetafile, emf_enum_proc, dx, NULL),
......
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