From 54ec86021a7d2b8ef3eb7ce6967797709834c260 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 14 Jul 2016 14:28:13 +0100 Subject: [PATCH] gdi32: Change get_gdi_flat_path() to return an opaque path pointer. Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/gdi32/dibdrv/graphics.c | 9 ++++----- dlls/gdi32/enhmfdrv/graphics.c | 11 +++++------ dlls/gdi32/gdi_private.h | 3 ++- dlls/gdi32/path.c | 25 ++++++++++++------------- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c index bfb345143a0..64f6d154153 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,8 @@ 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 ); - if (total == -1) return FALSE; - if (!total) goto done; + if (!(path = get_gdi_flat_path( dev->dev.hdc, fill ? &interior : NULL ))) return FALSE; + if (!(total = get_gdi_path_data( path, &points, &types ))) goto done; if (stroke && dev->pen_uses_region) outline = CreateRectRgn( 0, 0, 0, 0 ); @@ -464,8 +464,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 1dd345c00a5..f74e86b086b 100644 --- a/dlls/gdi32/enhmfdrv/graphics.c +++ b/dlls/gdi32/enhmfdrv/graphics.c @@ -100,24 +100,23 @@ 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; - int count; + struct gdi_path *path; POINT *points; BYTE *flags; emr.emr.iType = type; emr.emr.nSize = sizeof(emr); - count = get_gdi_flat_path( dev->hdc, &points, &flags, NULL ); - if (count >= 0) + if ((path = get_gdi_flat_path( dev->hdc, NULL ))) { + int count = 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; if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE; - if (count < 0) return FALSE; + if (!path) return FALSE; EMFDRV_UpdateBBox( dev, &emr.rclBounds ); return TRUE; } diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index 8bdf9f12698..b4768640210 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -337,7 +337,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 struct gdi_path *get_gdi_flat_path( HDC hdc, 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 86c16990de6..2ee113e0a7f 100644 --- a/dlls/gdi32/path.c +++ b/dlls/gdi32/path.c @@ -514,29 +514,22 @@ 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 ) +struct gdi_path *get_gdi_flat_path( HDC hdc, HRGN *rgn ) { DC *dc = get_dc_ptr( hdc ); - int ret = -1; + struct gdi_path *ret = NULL; - if (!dc) return -1; + if (!dc) return NULL; if (dc->path) { - struct gdi_path *path = PATH_FlattenPath( dc->path ); + ret = PATH_FlattenPath( dc->path ); free_gdi_path( dc->path ); dc->path = NULL; - if (path) - { - ret = path->count; - *points = path->points; - *flags = path->flags; - if (rgn) *rgn = path_to_region( path, GetPolyFillMode( hdc )); - HeapFree( GetProcessHeap(), 0, path ); - } + if (ret && rgn) *rgn = path_to_region( ret, GetPolyFillMode( hdc ) ); } else SetLastError( ERROR_CAN_NOT_COMPLETE ); @@ -544,6 +537,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.@)