From 1b7a15e4cc96f85078c031d8e7ba0aa2d2b482b2 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 22 Jul 2021 11:25:17 +0200 Subject: [PATCH] gdi32: Use NtGdiPolyPolyDraw for PolyPolygon 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/enhmetafiledrv.h | 1 + dlls/gdi32/enhmfdrv/graphics.c | 12 ++++++++++-- dlls/gdi32/gdi_private.h | 4 ++++ dlls/gdi32/gdidc.c | 15 ++++++++++++++ dlls/gdi32/mfdrv/graphics.c | 6 +++--- dlls/gdi32/mfdrv/init.c | 10 +++++++++- dlls/gdi32/mfdrv/metafiledrv.h | 2 +- dlls/gdi32/painting.c | 29 ++++++++++++++++++---------- include/ntgdi.h | 10 ++++++++++ 10 files changed, 73 insertions(+), 30 deletions(-) diff --git a/dlls/gdi32/enhmfdrv/dc.c b/dlls/gdi32/enhmfdrv/dc.c index 7e09216cdea..880b1c3fc6b 100644 --- a/dlls/gdi32/enhmfdrv/dc.c +++ b/dlls/gdi32/enhmfdrv/dc.c @@ -707,18 +707,6 @@ static BOOL CDECL emfpathdrv_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE next->funcs->pPolyDraw( next, pts, types, count )); } -/*********************************************************************** - * emfpathdrv_PolyPolygon - */ -static BOOL CDECL emfpathdrv_PolyPolygon( PHYSDEV dev, const POINT *pts, const INT *counts, UINT polygons ) -{ - PHYSDEV emfdev = get_emfdev( dev ); - PHYSDEV next = GET_NEXT_PHYSDEV( dev, pPolyPolygon ); - - return (emfdev->funcs->pPolyPolygon( emfdev, pts, counts, polygons ) && - next->funcs->pPolyPolygon( next, pts, counts, polygons )); -} - /*********************************************************************** * emfpathdrv_PolyPolyline */ @@ -842,7 +830,7 @@ static const struct gdi_dc_funcs emfpath_driver = emfpathdrv_PolyBezier, /* pPolyBezier */ emfpathdrv_PolyBezierTo, /* pPolyBezierTo */ emfpathdrv_PolyDraw, /* pPolyDraw */ - emfpathdrv_PolyPolygon, /* pPolyPolygon */ + NULL, /* pPolyPolygon */ emfpathdrv_PolyPolyline, /* pPolyPolyline */ emfpathdrv_Polygon, /* pPolygon */ emfpathdrv_Polyline, /* pPolyline */ diff --git a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h index dd4ed6ad4d2..e47b4b558ca 100644 --- a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h +++ b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h @@ -27,6 +27,7 @@ #include "winbase.h" #include "wingdi.h" #include "ntgdi_private.h" +#include "gdi_private.h" /* Enhanced Metafile driver physical DC */ diff --git a/dlls/gdi32/enhmfdrv/graphics.c b/dlls/gdi32/enhmfdrv/graphics.c index 90d22e1f3ef..20d9f3b7b90 100644 --- a/dlls/gdi32/enhmfdrv/graphics.c +++ b/dlls/gdi32/enhmfdrv/graphics.c @@ -692,15 +692,23 @@ BOOL CDECL EMFDRV_PolyPolyline(PHYSDEV dev, const POINT* pt, const DWORD* counts EMR_POLYPOLYLINE ); } +/********************************************************************** + * EMFDC_PolyPolygon + */ +BOOL EMFDC_PolyPolygon( DC_ATTR *dc_attr, const POINT *pt, const INT *counts, UINT polys ) +{ + return EMFDRV_PolyPolylinegon( dc_attr->emf, pt, counts, polys, EMR_POLYPOLYGON ); +} + /********************************************************************** * EMFDRV_PolyPolygon */ BOOL CDECL EMFDRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT polys ) { - return EMFDRV_PolyPolylinegon( dev, pt, counts, polys, EMR_POLYPOLYGON ); + /* FIXME: update bounding rect */ + return TRUE; } - /********************************************************************** * EMFDRV_PolyDraw */ diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index 1dfd3b2424c..6d4eda376f8 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -51,6 +51,8 @@ extern BOOL METADC_LineTo( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN; extern BOOL METADC_MoveTo( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN; extern BOOL METADC_Pie( HDC hdc, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN; +extern BOOL METADC_PolyPolygon( HDC hdc, const POINT *points, const INT *counts, + UINT polygons ) DECLSPEC_HIDDEN; extern BOOL METADC_Rectangle( HDC hdc, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN; extern BOOL METADC_RoundRect( HDC hdc, INT left, INT top, INT right, INT bottom, INT ell_width, INT ell_height ) DECLSPEC_HIDDEN; @@ -65,6 +67,8 @@ extern BOOL EMFDC_Ellipse( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN; 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_PolyPolygon( DC_ATTR *dc_attr, const POINT *points, const INT *counts, + UINT polys ) DECLSPEC_HIDDEN; extern BOOL EMFDC_Rectangle( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN; extern BOOL EMFDC_RoundRect( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom, diff --git a/dlls/gdi32/gdidc.c b/dlls/gdi32/gdidc.c index 2e31297d7d9..49d91ff72f5 100644 --- a/dlls/gdi32/gdidc.c +++ b/dlls/gdi32/gdidc.c @@ -236,3 +236,18 @@ BOOL WINAPI RoundRect( HDC hdc, INT left, INT top, INT right, return NtGdiRoundRect( hdc, left, top, right, bottom, ell_width, ell_height ); } + +/********************************************************************** + * PolyPolygon (GDI32.@) + */ +BOOL WINAPI PolyPolygon( HDC hdc, const POINT *points, const INT *counts, UINT polygons ) +{ + DC_ATTR *dc_attr; + + TRACE( "%p, %p, %p, %u\n", hdc, points, counts, polygons ); + + if (is_meta_dc( hdc )) return METADC_PolyPolygon( hdc, points, counts, polygons ); + if (!(dc_attr = get_dc_attr( hdc ))) return FALSE; + if (dc_attr->emf && !EMFDC_PolyPolygon( dc_attr, points, counts, polygons )) return FALSE; + return NtGdiPolyPolyDraw( hdc, points, (const UINT *)counts, polygons, NtGdiPolyPolygon ); +} diff --git a/dlls/gdi32/mfdrv/graphics.c b/dlls/gdi32/mfdrv/graphics.c index 37da92185af..b4ee4939848 100644 --- a/dlls/gdi32/mfdrv/graphics.c +++ b/dlls/gdi32/mfdrv/graphics.c @@ -195,9 +195,9 @@ BOOL CDECL MFDRV_Polygon( PHYSDEV dev, const POINT* pt, INT count ) /********************************************************************** - * MFDRV_PolyPolygon + * METADC_PolyPolygon */ -BOOL CDECL MFDRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT polygons) +BOOL METADC_PolyPolygon( HDC hdc, const POINT *pt, const INT *counts, UINT polygons ) { BOOL ret; DWORD len; @@ -239,7 +239,7 @@ BOOL CDECL MFDRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, U *(mr->rdParm) = polygons; memcpy(mr->rdParm + 1, pointcounts, polygons*sizeof(INT16)); memcpy(mr->rdParm + 1+polygons, pts , totalpoint16*sizeof(*pts)); - ret = MFDRV_WriteRecord( dev, mr, mr->rdSize * 2); + ret = metadc_record( hdc, mr, mr->rdSize * 2); HeapFree( GetProcessHeap(), 0, pts ); HeapFree( GetProcessHeap(), 0, pointcounts ); diff --git a/dlls/gdi32/mfdrv/init.c b/dlls/gdi32/mfdrv/init.c index df4d9dc9541..0f2760ade35 100644 --- a/dlls/gdi32/mfdrv/init.c +++ b/dlls/gdi32/mfdrv/init.c @@ -171,7 +171,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs = MFDRV_PolyBezier, /* pPolyBezier */ MFDRV_PolyBezierTo, /* pPolyBezierTo */ NULL, /* pPolyDraw */ - MFDRV_PolyPolygon, /* pPolyPolygon */ + NULL, /* pPolyPolygon */ NULL, /* pPolyPolyline */ MFDRV_Polygon, /* pPolygon */ MFDRV_Polyline, /* pPolyline */ @@ -606,6 +606,14 @@ static METAFILEDRV_PDEVICE *get_metadc_ptr( HDC hdc ) return metafile; } +BOOL metadc_record( HDC hdc, METARECORD *mr, DWORD rlen ) +{ + METAFILEDRV_PDEVICE *dev; + + if (!(dev = get_metadc_ptr( hdc ))) return FALSE; + return MFDRV_WriteRecord( &dev->dev, mr, rlen ); +} + BOOL metadc_param2( HDC hdc, short func, short param1, short param2 ) { METAFILEDRV_PDEVICE *dev; diff --git a/dlls/gdi32/mfdrv/metafiledrv.h b/dlls/gdi32/mfdrv/metafiledrv.h index 66375295cd9..a168782efda 100644 --- a/dlls/gdi32/mfdrv/metafiledrv.h +++ b/dlls/gdi32/mfdrv/metafiledrv.h @@ -67,6 +67,7 @@ extern BOOL metadc_param6( HDC hdc, short func, short param1, short param2, shor extern BOOL metadc_param8( HDC hdc, short func, short param1, short param2, short param3, short param4, short param5, short param6, short param7, short param8 ) DECLSPEC_HIDDEN; +extern BOOL metadc_record( HDC hdc, METARECORD *mr, DWORD rlen ) DECLSPEC_HIDDEN; /* Metafile driver functions */ @@ -95,7 +96,6 @@ extern BOOL CDECL MFDRV_PaintRgn( PHYSDEV dev, HRGN hrgn ) DECLSPEC_HIDDEN; extern BOOL CDECL MFDRV_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop ) DECLSPEC_HIDDEN; extern BOOL CDECL MFDRV_PolyBezier( PHYSDEV dev, const POINT* pt, DWORD count ) DECLSPEC_HIDDEN; extern BOOL CDECL MFDRV_PolyBezierTo( PHYSDEV dev, const POINT* pt, DWORD count ) DECLSPEC_HIDDEN; -extern BOOL CDECL MFDRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT polygons) DECLSPEC_HIDDEN; extern BOOL CDECL MFDRV_Polygon( PHYSDEV dev, const POINT* pt, INT count ) DECLSPEC_HIDDEN; extern BOOL CDECL MFDRV_Polyline( PHYSDEV dev, const POINT* pt,INT count) DECLSPEC_HIDDEN; extern BOOL CDECL MFDRV_RestoreDC( PHYSDEV dev, INT level ) DECLSPEC_HIDDEN; diff --git a/dlls/gdi32/painting.c b/dlls/gdi32/painting.c index ba3f886519b..b2c60627528 100644 --- a/dlls/gdi32/painting.c +++ b/dlls/gdi32/painting.c @@ -634,21 +634,30 @@ BOOL WINAPI Polygon( HDC hdc, const POINT* pt, INT count ) /********************************************************************** - * PolyPolygon (GDI32.@) + * NtGdiPolyPolyDraw (win32u.@) */ -BOOL WINAPI PolyPolygon( HDC hdc, const POINT* pt, const INT* counts, - UINT polygons ) +ULONG WINAPI NtGdiPolyPolyDraw( HDC hdc, const POINT *points, const UINT *counts, + UINT count, UINT function ) { PHYSDEV physdev; - BOOL ret; - DC * dc = get_dc_ptr( hdc ); + ULONG ret; + DC *dc; - TRACE( "%p, %p, %p, %u\n", hdc, pt, counts, polygons ); - - if (!dc) return FALSE; + if (!(dc = get_dc_ptr( hdc ))) return FALSE; update_dc( dc ); - physdev = GET_DC_PHYSDEV( dc, pPolyPolygon ); - ret = physdev->funcs->pPolyPolygon( physdev, pt, counts, polygons ); + + switch (function) + { + case NtGdiPolyPolygon: + physdev = GET_DC_PHYSDEV( dc, pPolyPolygon ); + ret = physdev->funcs->pPolyPolygon( physdev, points, (const INT *)counts, count ); + break; + default: + WARN( "invalid function %u\n", function ); + ret = FALSE; + break; + } + release_dc_ptr( dc ); return ret; } diff --git a/include/ntgdi.h b/include/ntgdi.h index 4d1d6a48c4f..dce35a8b0b8 100644 --- a/include/ntgdi.h +++ b/include/ntgdi.h @@ -83,6 +83,16 @@ enum NtGdiPie, }; +enum +{ + NtGdiPolyPolygon = 1, + NtGdiPolyPolyline, + NtGdiPolyBezier, + NtGdiPolyBezierTo, + NtGdiPolylineTo, + NtGdiPolyPolygonRgn, +}; + /* structs not compatible with native Windows */ #ifdef __WINESRC__