gdi32: Use NtGdiPolyDraw for PolyDraw implementation.

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:48:48 +02:00 committed by Alexandre Julliard
parent f838d5a2b9
commit 11f09c2d74
6 changed files with 47 additions and 27 deletions

View file

@ -671,18 +671,6 @@ static BOOL CDECL emfpathdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
next->funcs->pExtTextOut( next, x, y, flags, rect, str, count, dx ));
}
/***********************************************************************
* emfpathdrv_PolyDraw
*/
static BOOL CDECL emfpathdrv_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE *types, DWORD count )
{
PHYSDEV emfdev = get_emfdev( dev );
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pPolyDraw );
return (emfdev->funcs->pPolyDraw( emfdev, pts, types, count ) &&
next->funcs->pPolyDraw( next, pts, types, count ));
}
static const struct gdi_dc_funcs emfpath_driver =
{
@ -757,7 +745,7 @@ static const struct gdi_dc_funcs emfpath_driver =
NULL, /* pPie */
NULL, /* pPolyBezier */
NULL, /* pPolyBezierTo */
emfpathdrv_PolyDraw, /* pPolyDraw */
NULL, /* pPolyDraw */
NULL, /* pPolyPolygon */
NULL, /* pPolyPolyline */
NULL, /* pPolylineTo */

View file

@ -741,11 +741,11 @@ BOOL CDECL EMFDRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts,
}
/**********************************************************************
* EMFDRV_PolyDraw
* EMFDC_PolyDraw
*/
BOOL CDECL EMFDRV_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE *types, DWORD count )
BOOL EMFDC_PolyDraw( DC_ATTR *dc_attr, const POINT *pts, const BYTE *types, DWORD count )
{
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMFDRV_PDEVICE *emf = dc_attr->emf;
EMRPOLYDRAW *emr;
BOOL ret;
BYTE *types_dest;
@ -765,18 +765,28 @@ BOOL CDECL EMFDRV_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE *types, DW
memcpy( types_dest, types, count );
if (count & 3) memset( types_dest + count, 0, 4 - (count & 3) );
if (!physDev->path)
if (!emf->path)
get_points_bounds( &emr->rclBounds, pts, count, 0 );
else
emr->rclBounds = empty_bounds;
ret = EMFDRV_WriteRecord( dev, &emr->emr );
if (ret && !physDev->path) EMFDRV_UpdateBBox( dev, &emr->rclBounds );
ret = EMFDRV_WriteRecord( &emf->dev, &emr->emr );
if (ret && !emf->path) EMFDRV_UpdateBBox( &emf->dev, &emr->rclBounds );
HeapFree( GetProcessHeap(), 0, emr );
return ret;
}
/**********************************************************************
* EMFDRV_PolyDraw
*/
BOOL CDECL EMFDRV_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE *types, DWORD count )
{
/* FIXME: update bounding rect */
return TRUE;
}
/**********************************************************************
* EMFDRV_ExtFloodFill
*/

View file

@ -71,6 +71,8 @@ extern BOOL EMFDC_LineTo( DC_ATTR *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_MoveTo( DC_ATTR *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_PolyBezier( DC_ATTR *dc_attr, const POINT *points, DWORD count ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_PolyBezierTo( DC_ATTR *dc_attr, const POINT *points, DWORD count ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_PolyDraw( DC_ATTR *dc_attr, const POINT *points, const BYTE *types,
DWORD count ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_PolyPolyline( DC_ATTR *dc_attr, const POINT *points, const DWORD *counts,
DWORD polys ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_PolyPolygon( DC_ATTR *dc_attr, const POINT *points, const INT *counts,

View file

@ -337,3 +337,17 @@ BOOL WINAPI PolylineTo( HDC hdc, const POINT *points, DWORD count )
if (dc_attr->emf && !EMFDC_PolylineTo( dc_attr, points, count )) return FALSE;
return NtGdiPolyPolyDraw( hdc, points, &count, 1, NtGdiPolylineTo );
}
/***********************************************************************
* PolyDraw (GDI32.@)
*/
BOOL WINAPI PolyDraw( HDC hdc, const POINT *points, const BYTE *types, DWORD count )
{
DC_ATTR *dc_attr;
TRACE( "%p, %p, %p, %u\n", hdc, points, types, count );
if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
if (dc_attr->emf && !EMFDC_PolyDraw( dc_attr, points, types, count )) return FALSE;
return NtGdiPolyDraw( hdc, points, types, count );
}

View file

@ -699,24 +699,21 @@ BOOL WINAPI NtGdiAngleArc( HDC hdc, INT x, INT y, DWORD dwRadius, FLOAT eStartAn
}
/***********************************************************************
* PolyDraw (GDI32.@)
* NtGdiPolyDraw (win32u.@)
*/
BOOL WINAPI PolyDraw(HDC hdc, const POINT *lppt, const BYTE *lpbTypes,
DWORD cCount)
BOOL WINAPI NtGdiPolyDraw( HDC hdc, const POINT *points, const BYTE *types, DWORD count )
{
DC *dc = get_dc_ptr( hdc );
PHYSDEV physdev;
BOOL result;
TRACE( "%p, %p, %p, %u\n", hdc, lppt, lpbTypes, cCount );
if(!dc) return FALSE;
update_dc( dc );
physdev = GET_DC_PHYSDEV( dc, pPolyDraw );
result = physdev->funcs->pPolyDraw( physdev, lppt, lpbTypes, cCount );
if (result && cCount)
dc->attr->cur_pos = lppt[cCount - 1];
result = physdev->funcs->pPolyDraw( physdev, points, types, count );
if (result && count)
dc->attr->cur_pos = points[count - 1];
release_dc_ptr( dc );
return result;

View file

@ -3324,6 +3324,9 @@ static void test_mf_Graphics(void)
INT type;
BOOL ret;
static const POINT points[] = { {1, 1}, {2, 2} };
static const BYTE types[] = { PT_MOVETO, PT_LINETO };
hdcMetafile = CreateMetaFileA(NULL);
ok(hdcMetafile != 0, "CreateMetaFileA(NULL) error %d\n", GetLastError());
@ -3344,6 +3347,12 @@ static void test_mf_Graphics(void)
ret = ArcTo(hdcMetafile, 1, 2, 30, 40, 11, 12, 23, 24 );
ok( !ret, "ArcTo succeeded\n" );
SetLastError(0xdeadbeef);
ret = PolyDraw(hdcMetafile, points, types, ARRAY_SIZE(points));
ok(!ret, "PolyDraw succeeded\n");
todo_wine
ok(GetLastError() == 0xdeadbeef, "GetLastError() = %u\n", GetLastError());
hMetafile = CloseMetaFile(hdcMetafile);
ok(hMetafile != 0, "CloseMetaFile error %d\n", GetLastError());
type = GetObjectType(hdcMetafile);