gdi32: Don't restore DC state in EnumEnhMetaFile when using metafiles.

Querying state is not supported on metafiles.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-08-03 12:55:40 +02:00 committed by Alexandre Julliard
parent 5de4766475
commit 3c6075e4b4
1 changed files with 14 additions and 23 deletions

View File

@ -2415,26 +2415,27 @@ BOOL WINAPI EnumEnhMetaFile(
info->state.next = NULL; info->state.next = NULL;
info->save_level = 0; info->save_level = 0;
info->saved_state = NULL; info->saved_state = NULL;
info->init_transform = info->state.world_transform;
ht = (HANDLETABLE*) &info[1]; ht = (HANDLETABLE*) &info[1];
ht->objectHandle[0] = hmf; ht->objectHandle[0] = hmf;
for(i = 1; i < emh->nHandles; i++) for(i = 1; i < emh->nHandles; i++)
ht->objectHandle[i] = NULL; ht->objectHandle[i] = NULL;
if(hdc) if (hdc && !is_meta_dc( hdc ))
{ {
savedMode = SetGraphicsMode(hdc, GM_ADVANCED); savedMode = SetGraphicsMode(hdc, GM_ADVANCED);
GetWorldTransform(hdc, &savedXform); GetWorldTransform(hdc, &savedXform);
GetViewportExtEx(hdc, &vp_size); GetViewportExtEx(hdc, &vp_size);
GetWindowExtEx(hdc, &win_size); GetWindowExtEx(hdc, &win_size);
GetViewportOrgEx(hdc, &vp_org); GetViewportOrgEx(hdc, &vp_org);
GetWindowOrgEx(hdc, &win_org); GetWindowOrgEx(hdc, &win_org);
mapMode = GetMapMode(hdc); mapMode = GetMapMode(hdc);
/* save DC */ /* save DC */
hPen = GetCurrentObject(hdc, OBJ_PEN); hPen = GetCurrentObject(hdc, OBJ_PEN);
hBrush = GetCurrentObject(hdc, OBJ_BRUSH); hBrush = GetCurrentObject(hdc, OBJ_BRUSH);
hFont = GetCurrentObject(hdc, OBJ_FONT); hFont = GetCurrentObject(hdc, OBJ_FONT);
hRgn = NtGdiCreateRectRgn(0, 0, 0, 0); hRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
if (!GetClipRgn(hdc, hRgn)) if (!GetClipRgn(hdc, hRgn))
@ -2451,17 +2452,7 @@ BOOL WINAPI EnumEnhMetaFile(
old_polyfill = SetPolyFillMode(hdc, ALTERNATE); old_polyfill = SetPolyFillMode(hdc, ALTERNATE);
old_stretchblt = SetStretchBltMode(hdc, BLACKONWHITE); old_stretchblt = SetStretchBltMode(hdc, BLACKONWHITE);
if ( IS_WIN9X() ) if (!IS_WIN9X())
{
/* Win95 leaves the vp/win ext/org info alone */
info->init_transform.eM11 = 1.0;
info->init_transform.eM12 = 0.0;
info->init_transform.eM21 = 0.0;
info->init_transform.eM22 = 1.0;
info->init_transform.eDx = 0.0;
info->init_transform.eDy = 0.0;
}
else
{ {
/* WinNT combines the vp/win ext/org info into a transform */ /* WinNT combines the vp/win ext/org info into a transform */
double xscale, yscale; double xscale, yscale;
@ -2505,7 +2496,7 @@ BOOL WINAPI EnumEnhMetaFile(
} }
/* WinNT resets the current vp/win org/ext */ /* WinNT resets the current vp/win org/ext */
if ( !IS_WIN9X() ) if (!IS_WIN9X())
{ {
SetMapMode(hdc, MM_TEXT); SetMapMode(hdc, MM_TEXT);
SetWindowOrgEx(hdc, 0, 0, NULL); SetWindowOrgEx(hdc, 0, 0, NULL);
@ -2537,7 +2528,7 @@ BOOL WINAPI EnumEnhMetaFile(
offset += emr->nSize; offset += emr->nSize;
} }
if (hdc) if (hdc && !is_meta_dc( hdc ))
{ {
SetStretchBltMode(hdc, old_stretchblt); SetStretchBltMode(hdc, old_stretchblt);
SetPolyFillMode(hdc, old_polyfill); SetPolyFillMode(hdc, old_polyfill);
@ -2554,9 +2545,9 @@ BOOL WINAPI EnumEnhMetaFile(
ExtSelectClipRgn(hdc, hRgn, RGN_COPY); ExtSelectClipRgn(hdc, hRgn, RGN_COPY);
DeleteObject(hRgn); DeleteObject(hRgn);
SetWorldTransform(hdc, &savedXform); SetWorldTransform(hdc, &savedXform);
if (savedMode) if (savedMode)
SetGraphicsMode(hdc, savedMode); SetGraphicsMode(hdc, savedMode);
SetMapMode(hdc, mapMode); SetMapMode(hdc, mapMode);
SetWindowOrgEx(hdc, win_org.x, win_org.y, NULL); SetWindowOrgEx(hdc, win_org.x, win_org.y, NULL);
SetWindowExtEx(hdc, win_size.cx, win_size.cy, NULL); SetWindowExtEx(hdc, win_size.cx, win_size.cy, NULL);