From 11f09c2d74d0eaeeaba5f93544166f87881b7f40 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 23 Jul 2021 10:48:48 +0200 Subject: [PATCH] gdi32: Use NtGdiPolyDraw for PolyDraw implementation. Signed-off-by: Jacek Caban Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/gdi32/enhmfdrv/dc.c | 14 +------------- dlls/gdi32/enhmfdrv/graphics.c | 22 ++++++++++++++++------ dlls/gdi32/gdi_private.h | 2 ++ dlls/gdi32/gdidc.c | 14 ++++++++++++++ dlls/gdi32/painting.c | 13 +++++-------- dlls/gdi32/tests/metafile.c | 9 +++++++++ 6 files changed, 47 insertions(+), 27 deletions(-) diff --git a/dlls/gdi32/enhmfdrv/dc.c b/dlls/gdi32/enhmfdrv/dc.c index b2b6bb4866e..7af63eed23b 100644 --- a/dlls/gdi32/enhmfdrv/dc.c +++ b/dlls/gdi32/enhmfdrv/dc.c @@ -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 */ diff --git a/dlls/gdi32/enhmfdrv/graphics.c b/dlls/gdi32/enhmfdrv/graphics.c index 80cffdbdebf..7c800148cf8 100644 --- a/dlls/gdi32/enhmfdrv/graphics.c +++ b/dlls/gdi32/enhmfdrv/graphics.c @@ -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 */ diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index fd36712dfbc..f7b04be18dc 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -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, diff --git a/dlls/gdi32/gdidc.c b/dlls/gdi32/gdidc.c index c51892d3a9e..c6a8cbd567f 100644 --- a/dlls/gdi32/gdidc.c +++ b/dlls/gdi32/gdidc.c @@ -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 ); +} diff --git a/dlls/gdi32/painting.c b/dlls/gdi32/painting.c index 9c7081296df..f9fa18c4de0 100644 --- a/dlls/gdi32/painting.c +++ b/dlls/gdi32/painting.c @@ -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; diff --git a/dlls/gdi32/tests/metafile.c b/dlls/gdi32/tests/metafile.c index 4f72079a615..d9d43b80fc4 100644 --- a/dlls/gdi32/tests/metafile.c +++ b/dlls/gdi32/tests/metafile.c @@ -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);