From 7f888ea093be8643d167eec999b55b09e82fae58 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 23 Aug 2021 13:52:57 +0200 Subject: [PATCH] gdi32: Separate EMFDRV_PDEVICE and struct emf. Signed-off-by: Jacek Caban Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/gdi32/emfdrv.c | 9 +++++++-- dlls/gdi32/enhmfdrv/enhmetafiledrv.h | 6 ++---- dlls/gdi32/enhmfdrv/graphics.c | 18 +++++++++--------- dlls/gdi32/enhmfdrv/init.c | 9 +++++---- dlls/gdi32/enhmfdrv/objects.c | 2 +- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/dlls/gdi32/emfdrv.c b/dlls/gdi32/emfdrv.c index e6421ff560c..006e70cbd2d 100644 --- a/dlls/gdi32/emfdrv.c +++ b/dlls/gdi32/emfdrv.c @@ -19,9 +19,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "enhmfdrv/enhmetafiledrv.h" +#include "ntgdi_private.h" +typedef struct +{ + struct gdi_physdev dev; + INT dev_caps[COLORMGMTCAPS + 1]; +} EMFDRV_PDEVICE; + static inline EMFDRV_PDEVICE *get_emf_physdev( PHYSDEV dev ) { return CONTAINING_RECORD( dev, EMFDRV_PDEVICE, dev ); @@ -576,7 +582,6 @@ HDC WINAPI NtGdiCreateMetafileDC( HDC hdc ) free_dc_ptr( dc ); return 0; } - dc->attr->emf = physDev; push_dc_driver( &dc->physDev, &physDev->dev, &emfdrv_driver ); diff --git a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h index 288ceed518b..83c3bedfb7e 100644 --- a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h +++ b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h @@ -31,9 +31,8 @@ /* Enhanced Metafile driver physical DC */ -typedef struct emf +struct emf { - struct gdi_physdev dev; ENHMETAHEADER *emh; /* Pointer to enhanced metafile header */ DC_ATTR *dc_attr; UINT handles_size, cur_handles; @@ -42,8 +41,7 @@ typedef struct emf HBRUSH dc_brush; HPEN dc_pen; BOOL path; - INT dev_caps[COLORMGMTCAPS + 1]; -} EMFDRV_PDEVICE; +}; extern BOOL emfdc_record( struct emf *emf, EMR *emr ) DECLSPEC_HIDDEN; extern void emfdc_update_bounds( struct emf *emf, RECTL *rect ) DECLSPEC_HIDDEN; diff --git a/dlls/gdi32/enhmfdrv/graphics.c b/dlls/gdi32/enhmfdrv/graphics.c index 0c6d671c7d4..9ff16f285f0 100644 --- a/dlls/gdi32/enhmfdrv/graphics.c +++ b/dlls/gdi32/enhmfdrv/graphics.c @@ -637,14 +637,14 @@ BOOL EMFDC_ExtTextOut( DC_ATTR *dc_attr, INT x, INT y, UINT flags, const RECT *l if (graphicsMode == GM_COMPATIBLE) { - const INT horzSize = GetDeviceCaps( emf->dev.hdc, HORZSIZE ); - const INT horzRes = GetDeviceCaps( emf->dev.hdc, HORZRES ); - const INT vertSize = GetDeviceCaps( emf->dev.hdc, VERTSIZE ); - const INT vertRes = GetDeviceCaps( emf->dev.hdc, VERTRES ); + const INT horzSize = GetDeviceCaps( dc_attr->hdc, HORZSIZE ); + const INT horzRes = GetDeviceCaps( dc_attr->hdc, HORZRES ); + const INT vertSize = GetDeviceCaps( dc_attr->hdc, VERTSIZE ); + const INT vertRes = GetDeviceCaps( dc_attr->hdc, VERTRES ); SIZE wndext, vportext; - GetViewportExtEx( emf->dev.hdc, &vportext ); - GetWindowExtEx( emf->dev.hdc, &wndext ); + GetViewportExtEx( dc_attr->hdc, &vportext ); + GetWindowExtEx( dc_attr->hdc, &wndext ); exScale = 100.0 * ((FLOAT)horzSize / (FLOAT)horzRes) / ((FLOAT)wndext.cx / (FLOAT)vportext.cx); eyScale = 100.0 * ((FLOAT)vertSize / (FLOAT)vertRes) / @@ -685,7 +685,7 @@ BOOL EMFDC_ExtTextOut( DC_ATTR *dc_attr, INT x, INT y, UINT flags, const RECT *l for (i = 0; i < count; i++) { textWidth += lpDx[i]; } - if (GetTextExtentPoint32W( emf->dev.hdc, str, count, &strSize )) + if (GetTextExtentPoint32W( dc_attr->hdc, str, count, &strSize )) textHeight = strSize.cy; } else { @@ -693,7 +693,7 @@ BOOL EMFDC_ExtTextOut( DC_ATTR *dc_attr, INT x, INT y, UINT flags, const RECT *l INT *dx = (INT *)((char*)pemr + pemr->emrtext.offDx); SIZE charSize; for (i = 0; i < count; i++) { - if (GetTextExtentPoint32W( emf->dev.hdc, str + i, 1, &charSize )) { + if (GetTextExtentPoint32W( dc_attr->hdc, str + i, 1, &charSize )) { dx[i] = charSize.cx; textWidth += charSize.cx; textHeight = max(textHeight, charSize.cy); @@ -729,7 +729,7 @@ BOOL EMFDC_ExtTextOut( DC_ATTR *dc_attr, INT x, INT y, UINT flags, const RECT *l switch (textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE)) { case TA_BASELINE: { TEXTMETRICW tm; - if (!GetTextMetricsW( emf->dev.hdc, &tm )) + if (!GetTextMetricsW( dc_attr->hdc, &tm )) tm.tmDescent = 0; /* Play safe here... it's better to have a bounding box */ /* that is too big than too small. */ diff --git a/dlls/gdi32/enhmfdrv/init.c b/dlls/gdi32/enhmfdrv/init.c index 1c99b23984a..66701caa19b 100644 --- a/dlls/gdi32/enhmfdrv/init.c +++ b/dlls/gdi32/enhmfdrv/init.c @@ -41,7 +41,7 @@ void EMFDC_DeleteDC( DC_ATTR *dc_attr ) HeapFree( GetProcessHeap(), 0, emf->emh ); for (index = 0; index < emf->handles_size; index++) if (emf->handles[index]) - GDI_hdc_not_using_object( emf->handles[index], emf->dev.hdc ); + GDI_hdc_not_using_object( emf->handles[index], dc_attr->hdc ); HeapFree( GetProcessHeap(), 0, emf->handles ); } @@ -85,7 +85,7 @@ void emfdc_update_bounds( struct emf *emf, RECTL *rect ) RECTL *bounds = &emf->dc_attr->emf_bounds; RECTL vportRect = *rect; - LPtoDP( emf->dev.hdc, (POINT *)&vportRect, 2 ); + LPtoDP( emf->dc_attr->hdc, (POINT *)&vportRect, 2 ); /* The coordinate systems may be mirrored (LPtoDP handles points, not rectangles) */ @@ -173,12 +173,13 @@ HDC WINAPI CreateEnhMetaFileW( if (!(ret = NtGdiCreateMetafileDC( hdc ))) return 0; - if (!(dc_attr = get_dc_attr( ret ))) + if (!(dc_attr = get_dc_attr( ret )) || !(emf = HeapAlloc( GetProcessHeap(), 0, sizeof(*emf) ))) { DeleteDC( ret ); return 0; } - emf = dc_attr->emf; + + dc_attr->emf = emf; if(description) { /* App name\0Title\0\0 */ length = lstrlenW(description); diff --git a/dlls/gdi32/enhmfdrv/objects.c b/dlls/gdi32/enhmfdrv/objects.c index 03172a0eb40..a37c2e03f87 100644 --- a/dlls/gdi32/enhmfdrv/objects.c +++ b/dlls/gdi32/enhmfdrv/objects.c @@ -284,7 +284,7 @@ static BOOL EMFDC_SelectFont( DC_ATTR *dc_attr, HFONT font ) if (!(index = emfdc_find_object( emf, font ))) { if (!(index = EMFDRV_CreateFontIndirect( emf, font ))) return FALSE; - GDI_hdc_using_object( font, emf->dev.hdc, EMFDC_DeleteObject ); + GDI_hdc_using_object( font, dc_attr->hdc, EMFDC_DeleteObject ); } found: