Jacek Caban : gdi32: Use NtGdiPolyPolyDraw for PolyBezier implementation.

Alexandre Julliard julliard at winehq.org
Thu Jul 22 16:28:19 CDT 2021


Module: wine
Branch: master
Commit: 5be1b7c75b298e3378d1627d08ce68853d016256
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=5be1b7c75b298e3378d1627d08ce68853d016256

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Jul 22 11:27:07 2021 +0200

gdi32: Use NtGdiPolyPolyDraw for PolyBezier implementation.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/enhmfdrv/dc.c       | 14 +------------
 dlls/gdi32/enhmfdrv/graphics.c | 11 +++++++++-
 dlls/gdi32/gdi_private.h       |  1 +
 dlls/gdi32/gdidc.c             | 14 +++++++++++++
 dlls/gdi32/painting.c          | 46 ++++++++++--------------------------------
 5 files changed, 37 insertions(+), 49 deletions(-)

diff --git a/dlls/gdi32/enhmfdrv/dc.c b/dlls/gdi32/enhmfdrv/dc.c
index e8b6c8e74ae..d387d4810ab 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_PolyBezier
- */
-static BOOL CDECL emfpathdrv_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD count )
-{
-    PHYSDEV emfdev = get_emfdev( dev );
-    PHYSDEV next = GET_NEXT_PHYSDEV( dev, pPolyBezier );
-
-    return (emfdev->funcs->pPolyBezier( emfdev, pts, count ) &&
-            next->funcs->pPolyBezier( next, pts, count ));
-}
-
 /***********************************************************************
  *           emfpathdrv_PolyBezierTo
  */
@@ -791,7 +779,7 @@ static const struct gdi_dc_funcs emfpath_driver =
     NULL,                               /* pPaintRgn */
     NULL,                               /* pPatBlt */
     NULL,                               /* pPie */
-    emfpathdrv_PolyBezier,              /* pPolyBezier */
+    NULL,                               /* pPolyBezier */
     emfpathdrv_PolyBezierTo,            /* pPolyBezierTo */
     emfpathdrv_PolyDraw,                /* pPolyDraw */
     NULL,                               /* pPolyPolygon */
diff --git a/dlls/gdi32/enhmfdrv/graphics.c b/dlls/gdi32/enhmfdrv/graphics.c
index 0c6c581b490..082432fa079 100644
--- a/dlls/gdi32/enhmfdrv/graphics.c
+++ b/dlls/gdi32/enhmfdrv/graphics.c
@@ -608,12 +608,21 @@ BOOL EMFDC_Polygon( DC_ATTR *dc_attr, const POINT *pt, INT count )
     return EMFDRV_Polylinegon( dc_attr->emf, pt, count, EMR_POLYGON );
 }
 
+/**********************************************************************
+ *          EMFDC_PolyBezier
+ */
+BOOL EMFDC_PolyBezier( DC_ATTR *dc_attr, const POINT *pts, DWORD count )
+{
+    return EMFDRV_Polylinegon( dc_attr->emf, pts, count, EMR_POLYBEZIER );
+}
+
 /**********************************************************************
  *          EMFDRV_PolyBezier
  */
 BOOL CDECL EMFDRV_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD count )
 {
-    return EMFDRV_Polylinegon( dev, pts, count, EMR_POLYBEZIER );
+    /* FIXME: update bounding rect */
+    return TRUE;
 }
 
 /**********************************************************************
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index 53df73f1717..fcb7195b302 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -69,6 +69,7 @@ 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_PolyBezier( DC_ATTR *dc_attr, const POINT *points, 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 8486a7c5621..d7cd6a45f14 100644
--- a/dlls/gdi32/gdidc.c
+++ b/dlls/gdi32/gdidc.c
@@ -295,3 +295,17 @@ BOOL WINAPI PolyPolyline( HDC hdc, const POINT *points, const DWORD *counts, DWO
     if (dc_attr->emf && !EMFDC_PolyPolyline( dc_attr, points, counts, polylines )) return FALSE;
     return NtGdiPolyPolyDraw( hdc, points, counts, polylines, NtGdiPolyPolyline );
 }
+
+/******************************************************************************
+ *          PolyBezier  (GDI32.@)
+ */
+BOOL WINAPI PolyBezier( HDC hdc, const POINT *points, DWORD count )
+{
+    DC_ATTR *dc_attr;
+
+    TRACE( "%p, %p, %u\n", hdc, points, count );
+
+    if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
+    if (dc_attr->emf && !EMFDC_PolyBezier( dc_attr, points, count )) return FALSE;
+    return NtGdiPolyPolyDraw( hdc, points, &count, 1, NtGdiPolyBezier );
+}
diff --git a/dlls/gdi32/painting.c b/dlls/gdi32/painting.c
index e4adb4301e3..ea353aaca9e 100644
--- a/dlls/gdi32/painting.c
+++ b/dlls/gdi32/painting.c
@@ -625,6 +625,17 @@ ULONG WINAPI NtGdiPolyPolyDraw( HDC hdc, const POINT *points, const UINT *counts
         ret = physdev->funcs->pPolyPolyline( physdev, points, counts, count );
         break;
 
+    case NtGdiPolyBezier:
+        /* *counts must be 3 * n + 1 (where n >= 1) */
+        if (count == 1 && *counts != 1 && *counts % 3 == 1)
+        {
+            physdev = GET_DC_PHYSDEV( dc, pPolyBezier );
+            ret = physdev->funcs->pPolyBezier( physdev, points, *counts );
+            if (ret) dc->attr->cur_pos = points[*counts - 1];
+        }
+        else ret = FALSE;
+        break;
+
     default:
         WARN( "invalid function %u\n", function );
         ret = FALSE;
@@ -664,41 +675,6 @@ BOOL WINAPI FloodFill( HDC hdc, INT x, INT y, COLORREF color )
     return ExtFloodFill( hdc, x, y, color, FLOODFILLBORDER );
 }
 
-
-/******************************************************************************
- * PolyBezier [GDI32.@]
- * Draws one or more Bezier curves
- *
- * PARAMS
- *    hDc     [I] Handle to device context
- *    lppt    [I] Pointer to endpoints and control points
- *    cPoints [I] Count of endpoints and control points
- *
- * RETURNS
- *    Success: TRUE
- *    Failure: FALSE
- */
-BOOL WINAPI PolyBezier( HDC hdc, const POINT* lppt, DWORD cPoints )
-{
-    PHYSDEV physdev;
-    BOOL ret;
-    DC * dc;
-
-    TRACE( "%p, %p, %u\n", hdc, lppt, cPoints );
-
-    /* cPoints must be 3 * n + 1 (where n>=1) */
-    if (cPoints == 1 || (cPoints % 3) != 1) return FALSE;
-
-    dc = get_dc_ptr( hdc );
-    if(!dc) return FALSE;
-
-    update_dc( dc );
-    physdev = GET_DC_PHYSDEV( dc, pPolyBezier );
-    ret = physdev->funcs->pPolyBezier( physdev, lppt, cPoints );
-    release_dc_ptr( dc );
-    return ret;
-}
-
 /******************************************************************************
  * PolyBezierTo [GDI32.@]
  * Draws one or more Bezier curves




More information about the wine-cvs mailing list