gdi32: Use ntgdi interface for path functions.

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-07-23 10:50:37 +02:00 committed by Alexandre Julliard
parent 0f3173e7d9
commit 972cfaca1f
7 changed files with 77 additions and 49 deletions

View File

@ -484,32 +484,28 @@ DWORD CDECL EMFDRV_SetMapperFlags( PHYSDEV dev, DWORD flags )
return EMFDRV_WriteRecord( dev, &emr.emr ) ? flags : GDI_ERROR;
}
BOOL CDECL EMFDRV_AbortPath( PHYSDEV dev )
BOOL EMFDC_AbortPath( DC_ATTR *dc_attr )
{
EMFDRV_PDEVICE *emf = dc_attr->emf;
EMRABORTPATH emr;
emr.emr.iType = EMR_ABORTPATH;
emr.emr.nSize = sizeof(emr);
return EMFDRV_WriteRecord( dev, &emr.emr );
emf->path = FALSE;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
}
BOOL CDECL EMFDRV_BeginPath( PHYSDEV dev )
BOOL EMFDC_BeginPath( DC_ATTR *dc_attr )
{
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pBeginPath );
EMFDRV_PDEVICE *emf = dc_attr->emf;
EMRBEGINPATH emr;
DC *dc = get_physdev_dc( dev );
emr.emr.iType = EMR_BEGINPATH;
emr.emr.nSize = sizeof(emr);
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
if (physDev->path) return TRUE; /* already open */
if (!next->funcs->pBeginPath( next )) return FALSE;
push_dc_driver( &dc->physDev, &physDev->pathdev, &emfpath_driver );
physDev->path = TRUE;
if (!EMFDRV_WriteRecord( &emf->dev, &emr.emr )) return FALSE;
emf->path = TRUE;
return TRUE;
}
@ -523,15 +519,16 @@ BOOL EMFDC_CloseFigure( DC_ATTR *dc_attr )
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
}
BOOL CDECL EMFDRV_EndPath( PHYSDEV dev )
BOOL EMFDC_EndPath( DC_ATTR *dc_attr )
{
EMFDRV_PDEVICE *emf = dc_attr->emf;
EMRENDPATH emr;
emr.emr.iType = EMR_ENDPATH;
emr.emr.nSize = sizeof(emr);
EMFDRV_WriteRecord( dev, &emr.emr );
return FALSE; /* always fails without a path */
emf->path = FALSE;
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
}
BOOL CDECL EMFDRV_FlattenPath( PHYSDEV dev )

View File

@ -59,21 +59,18 @@ extern DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush ) DECLSPEC_H
#define HANDLE_LIST_INC 20
/* Metafile driver functions */
extern BOOL CDECL EMFDRV_AbortPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_AlphaBlend( PHYSDEV dev_dst, struct bitblt_coords *dst,
PHYSDEV dev_src, struct bitblt_coords *src, BLENDFUNCTION func ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_Arc( PHYSDEV dev, INT left, INT top, INT right,
INT bottom, INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_ArcTo( PHYSDEV dev, INT left, INT top, INT right,
INT bottom, INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_BeginPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_BitBlt( PHYSDEV devDst, INT xDst, INT yDst, INT width, INT height,
PHYSDEV devSrc, INT xSrc, INT ySrc, DWORD rop ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_DeleteObject( PHYSDEV dev, HGDIOBJ obj ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_EndPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern INT CDECL EMFDRV_ExcludeClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT fillType ) DECLSPEC_HIDDEN;
extern INT CDECL EMFDRV_ExtSelectClipRgn( PHYSDEV dev, HRGN hrgn, INT mode ) DECLSPEC_HIDDEN;

View File

@ -37,12 +37,12 @@ static BOOL CDECL EMFDRV_DeleteDC( PHYSDEV dev );
static const struct gdi_dc_funcs emfdrv_driver =
{
NULL, /* pAbortDoc */
EMFDRV_AbortPath, /* pAbortPath */
NULL, /* pAbortPath */
EMFDRV_AlphaBlend, /* pAlphaBlend */
NULL, /* pAngleArc */
EMFDRV_Arc, /* pArc */
EMFDRV_ArcTo, /* pArcTo */
EMFDRV_BeginPath, /* pBeginPath */
NULL, /* pBeginPath */
NULL, /* pBlendImage */
NULL, /* pChord */
NULL, /* pCloseFigure */
@ -54,7 +54,7 @@ static const struct gdi_dc_funcs emfdrv_driver =
EMFDRV_Ellipse, /* pEllipse */
NULL, /* pEndDoc */
NULL, /* pEndPage */
EMFDRV_EndPath, /* pEndPath */
NULL, /* pEndPath */
NULL, /* pEnumFonts */
NULL, /* pEnumICMProfiles */
EMFDRV_ExcludeClipRect, /* pExcludeClipRect */

View File

@ -62,14 +62,17 @@ extern BOOL METADC_RoundRect( HDC hdc, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
/* enhanced metafiles */
extern BOOL EMFDC_AbortPath( DC_ATTR *dc_attr ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_AngleArc( DC_ATTR *dc_attr, INT x, INT y, DWORD radius, FLOAT start,
FLOAT sweep ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_ArcChordPie( DC_ATTR *dc_attr, INT left, INT top, INT right,
INT bottom, INT xstart, INT ystart, INT xend,
INT yend, DWORD type ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_BeginPath( DC_ATTR *dc_attr ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_CloseFigure( DC_ATTR *dc_attr ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_Ellipse( DC_ATTR *dc_attr, INT left, INT top, INT right,
INT bottom ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_EndPath( DC_ATTR *dc_attr ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_ExtTextOut( DC_ATTR *dc_attr, INT x, INT y, UINT flags, const RECT *rect,
const WCHAR *str, UINT count, const INT *dx ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_LineTo( DC_ATTR *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN;

View File

@ -376,6 +376,42 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags, const RECT *rect,
return NtGdiExtTextOutW( hdc, x, y, flags, rect, str, count, dx, 0 );
}
/***********************************************************************
* BeginPath (GDI32.@)
*/
BOOL WINAPI BeginPath(HDC hdc)
{
DC_ATTR *dc_attr;
if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
if (dc_attr->emf && !EMFDC_BeginPath( dc_attr )) return FALSE;
return NtGdiBeginPath( hdc );
}
/***********************************************************************
* EndPath (GDI32.@)
*/
BOOL WINAPI EndPath(HDC hdc)
{
DC_ATTR *dc_attr;
if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
if (dc_attr->emf && !EMFDC_EndPath( dc_attr )) return FALSE;
return NtGdiEndPath( hdc );
}
/***********************************************************************
* AbortPath (GDI32.@)
*/
BOOL WINAPI AbortPath( HDC hdc )
{
DC_ATTR *dc_attr;
if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
if (dc_attr->emf && !EMFDC_AbortPath( dc_attr )) return FALSE;
return NtGdiAbortPath( hdc );
}
/***********************************************************************
* CloseFigure (GDI32.@)
*/

View File

@ -552,9 +552,9 @@ int get_gdi_path_data( struct gdi_path *path, POINT **pts, BYTE **flags )
}
/***********************************************************************
* BeginPath (GDI32.@)
* NtGdiBeginPath (win32u.@)
*/
BOOL WINAPI BeginPath(HDC hdc)
BOOL WINAPI NtGdiBeginPath( HDC hdc )
{
BOOL ret = FALSE;
DC *dc = get_dc_ptr( hdc );
@ -570,9 +570,9 @@ BOOL WINAPI BeginPath(HDC hdc)
/***********************************************************************
* EndPath (GDI32.@)
* NtGdiEndPath (win32u.@)
*/
BOOL WINAPI EndPath(HDC hdc)
BOOL WINAPI NtGdiEndPath( HDC hdc )
{
BOOL ret = FALSE;
DC *dc = get_dc_ptr( hdc );
@ -588,20 +588,9 @@ BOOL WINAPI EndPath(HDC hdc)
/******************************************************************************
* AbortPath [GDI32.@]
* Closes and discards paths from device context
*
* NOTES
* Check that SetLastError is being called correctly
*
* PARAMS
* hdc [I] Handle to device context
*
* RETURNS
* Success: TRUE
* Failure: FALSE
* NtGdiAbortPath (win32u.@)
*/
BOOL WINAPI AbortPath( HDC hdc )
BOOL WINAPI NtGdiAbortPath( HDC hdc )
{
BOOL ret = FALSE;
DC *dc = get_dc_ptr( hdc );
@ -2033,21 +2022,21 @@ BOOL CDECL nulldrv_SelectClipPath( PHYSDEV dev, INT mode )
BOOL CDECL nulldrv_FillPath( PHYSDEV dev )
{
if (GetPath( dev->hdc, NULL, NULL, 0 ) == -1) return FALSE;
AbortPath( dev->hdc );
NtGdiAbortPath( dev->hdc );
return TRUE;
}
BOOL CDECL nulldrv_StrokeAndFillPath( PHYSDEV dev )
{
if (GetPath( dev->hdc, NULL, NULL, 0 ) == -1) return FALSE;
AbortPath( dev->hdc );
NtGdiAbortPath( dev->hdc );
return TRUE;
}
BOOL CDECL nulldrv_StrokePath( PHYSDEV dev )
{
if (GetPath( dev->hdc, NULL, NULL, 0 ) == -1) return FALSE;
AbortPath( dev->hdc );
NtGdiAbortPath( dev->hdc );
return TRUE;
}

View File

@ -4829,17 +4829,17 @@ static const unsigned char EMF_PATH_BITS[] =
0x01, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
0x96, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00,
0x90, 0x01, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00,
0x70, 0x17, 0x00, 0x00, 0x70, 0x17, 0x00, 0x00,
0x08, 0x01, 0x00, 0x00, 0x09, 0x01, 0x00, 0x00,
0x7e, 0x0f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00,
0x20, 0x45, 0x4d, 0x46, 0x00, 0x00, 0x01, 0x00,
0xf8, 0x02, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
0x00, 0x03, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20, 0x03, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00,
0x40, 0x01, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00,
0x97, 0x06, 0x00, 0x00, 0xb1, 0x03, 0x00, 0x00,
0xbe, 0x01, 0x00, 0x00, 0xfa, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x04, 0x00,
0x80, 0xa9, 0x03, 0x00, 0x3b, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x90, 0xcf, 0x06, 0x00,
0xaf, 0xd0, 0x03, 0x00, 0x3b, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00,
0x32, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00,
@ -4912,6 +4912,7 @@ static const unsigned char EMF_PATH_BITS[] =
0x25, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x42,
0x00, 0x00, 0x34, 0x43, 0x3c, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
0x18, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
0x0a, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00,
@ -4991,11 +4992,16 @@ static void test_emf_paths(void)
PolyPolyline(hdcMetafile, pts, counts, 2);
PolyDraw(hdcMetafile, pts, types, 9);
AngleArc(hdcMetafile, 37, 36, 23, 90, 180);
EndPath(hdcMetafile);
ret = EndPath(hdcMetafile);
ok(ret, "EndPath failed: %u\n", GetLastError());
size = GetPath(hdcMetafile, NULL, NULL, 0);
ok( size == 112, "GetPath returned %d.\n", size);
/* EndPath with no open path is recorded, but fails */
ret = EndPath(hdcMetafile);
ok(!ret, "EndPath succeeded\n");
ret = StrokeAndFillPath( hdcMetafile );
ok( ret, "StrokeAndFillPath failed err %d\n", GetLastError() );
ret = StrokeAndFillPath( hdcMetafile );