Commit 54ec8602 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

gdi32: Change get_gdi_flat_path() to return an opaque path pointer.

parent 23751e0a
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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.@)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment