[PATCH 2/3] gdi32: Change get_gdi_flat_path() to return an opaque path pointer.

Huw Davies huw at codeweavers.com
Thu Jul 14 08:28:13 CDT 2016


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/gdi32/dibdrv/graphics.c   |  7 ++++---
 dlls/gdi32/enhmfdrv/graphics.c |  7 ++++---
 dlls/gdi32/gdi_private.h       |  3 ++-
 dlls/gdi32/path.c              | 21 ++++++++++++---------
 4 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c
index bfb3451..4093812 100644
--- a/dlls/gdi32/dibdrv/graphics.c
+++ b/dlls/gdi32/dibdrv/graphics.c
@@ -405,6 +405,7 @@ static BOOL draw_arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
 /* helper for path stroking and filling functions */
 static BOOL stroke_and_fill_path( dibdrv_physdev *dev, BOOL stroke, BOOL fill )
 {
+    struct gdi_path *path;
     POINT *points;
     BYTE *types;
     BOOL ret = TRUE;
@@ -413,9 +414,10 @@ static BOOL stroke_and_fill_path( dibdrv_physdev *dev, BOOL stroke, BOOL fill )
 
     if (dev->brush.style == BS_NULL) fill = FALSE;
 
-    total = get_gdi_flat_path( dev->dev.hdc, &points, &types, fill ? &interior : NULL );
+    total = get_gdi_flat_path( dev->dev.hdc, &path, fill ? &interior : NULL );
     if (total == -1) return FALSE;
     if (!total) goto done;
+    get_gdi_path_data( path, &points, &types );
 
     if (stroke && dev->pen_uses_region) outline = CreateRectRgn( 0, 0, 0, 0 );
 
@@ -464,8 +466,7 @@ static BOOL stroke_and_fill_path( dibdrv_physdev *dev, BOOL stroke, BOOL fill )
     }
 
 done:
-    HeapFree( GetProcessHeap(), 0, points );
-    HeapFree( GetProcessHeap(), 0, types );
+    free_gdi_path( path );
     return ret;
 }
 
diff --git a/dlls/gdi32/enhmfdrv/graphics.c b/dlls/gdi32/enhmfdrv/graphics.c
index 1dd345c..0be9455 100644
--- a/dlls/gdi32/enhmfdrv/graphics.c
+++ b/dlls/gdi32/enhmfdrv/graphics.c
@@ -100,6 +100,7 @@ static void get_points_bounds( RECTL *bounds, const POINT *pts, UINT count, HDC
 static BOOL emfdrv_stroke_and_fill_path( PHYSDEV dev, INT type )
 {
     EMRSTROKEANDFILLPATH emr;
+    struct gdi_path *path;
     int count;
     POINT *points;
     BYTE *flags;
@@ -107,12 +108,12 @@ static BOOL emfdrv_stroke_and_fill_path( PHYSDEV dev, INT type )
     emr.emr.iType = type;
     emr.emr.nSize = sizeof(emr);
 
-    count = get_gdi_flat_path( dev->hdc, &points, &flags, NULL );
+    count = get_gdi_flat_path( dev->hdc, &path, NULL );
     if (count >= 0)
     {
+        get_gdi_path_data( path, &points, &flags );
         get_points_bounds( &emr.rclBounds, points, count, 0 );
-        HeapFree( GetProcessHeap(), 0, points );
-        HeapFree( GetProcessHeap(), 0, flags );
+        free_gdi_path( path );
     }
     else emr.rclBounds = empty_bounds;
 
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index 79a7a74..d7e994e 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -336,7 +336,8 @@ typedef struct
 /* path.c */
 
 extern void free_gdi_path( struct gdi_path *path ) DECLSPEC_HIDDEN;
-extern int get_gdi_flat_path( HDC hdc, POINT **points, BYTE **flags, HRGN *rgn ) DECLSPEC_HIDDEN;
+extern int get_gdi_flat_path( HDC hdc, struct gdi_path **path, HRGN *rgn ) DECLSPEC_HIDDEN;
+extern int get_gdi_path_data( struct gdi_path *path, POINT **points, BYTE **flags ) DECLSPEC_HIDDEN;
 extern BOOL PATH_SavePath( DC *dst, DC *src ) DECLSPEC_HIDDEN;
 extern BOOL PATH_RestorePath( DC *dst, DC *src ) DECLSPEC_HIDDEN;
 
diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c
index 86c1699..af8bc21 100644
--- a/dlls/gdi32/path.c
+++ b/dlls/gdi32/path.c
@@ -514,9 +514,9 @@ static BOOL PATH_DoArcPart(struct gdi_path *pPath, FLOAT_POINT corners[],
 }
 
 /* retrieve a flattened path in device coordinates, and optionally its region */
-/* the DC path is deleted; the returned data must be freed by caller */
+/* the DC path is deleted; the returned data must be freed by caller using free_gdi_path() */
 /* helper for stroke_and_fill_path in the DIB driver */
-int get_gdi_flat_path( HDC hdc, POINT **points, BYTE **flags, HRGN *rgn )
+int get_gdi_flat_path( HDC hdc, struct gdi_path **path, HRGN *rgn )
 {
     DC *dc = get_dc_ptr( hdc );
     int ret = -1;
@@ -525,17 +525,14 @@ int get_gdi_flat_path( HDC hdc, POINT **points, BYTE **flags, HRGN *rgn )
 
     if (dc->path)
     {
-        struct gdi_path *path = PATH_FlattenPath( dc->path );
+        *path = PATH_FlattenPath( dc->path );
 
         free_gdi_path( dc->path );
         dc->path = NULL;
-        if (path)
+        if (*path)
         {
-            ret = path->count;
-            *points = path->points;
-            *flags = path->flags;
-            if (rgn) *rgn = path_to_region( path, GetPolyFillMode( hdc ));
-            HeapFree( GetProcessHeap(), 0, path );
+            ret = (*path)->count;
+            if (rgn) *rgn = path_to_region( *path, GetPolyFillMode( hdc ) );
         }
     }
     else SetLastError( ERROR_CAN_NOT_COMPLETE );
@@ -544,6 +541,12 @@ int get_gdi_flat_path( HDC hdc, POINT **points, BYTE **flags, HRGN *rgn )
     return ret;
 }
 
+int get_gdi_path_data( struct gdi_path *path, POINT **pts, BYTE **flags )
+{
+    *pts = path->points;
+    *flags = path->flags;
+    return path->count;
+}
 
 /***********************************************************************
  *           BeginPath    (GDI32.@)
-- 
2.7.4




More information about the wine-patches mailing list