gdi: initialize more dc values when enumerating an emf
Huw D M Davies
h.davies1 at physics.ox.ac.uk
Wed Oct 12 08:28:21 CDT 2005
Huw Davies <huw at codeweavers.com>
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.
--
Huw Davies
huw at codeweavers.com
Index: dlls/gdi/enhmetafile.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/enhmetafile.c,v
retrieving revision 1.14
diff -u -p -r1.14 enhmetafile.c
--- dlls/gdi/enhmetafile.c 12 Sep 2005 11:19:56 -0000 1.14
+++ dlls/gdi/enhmetafile.c 12 Oct 2005 13:22:20 -0000
@@ -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);
Index: dlls/gdi/tests/metafile.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/tests/metafile.c,v
retrieving revision 1.14
diff -u -p -r1.14 metafile.c
--- dlls/gdi/tests/metafile.c 12 Sep 2005 11:19:56 -0000 1.14
+++ dlls/gdi/tests/metafile.c 12 Oct 2005 13:22:20 -0000
@@ -55,6 +55,18 @@ static int CALLBACK emf_enum_proc(HDC hd
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),
More information about the wine-patches
mailing list