Commit bf528c5e authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Allow removing a driver from the stack based on its function table.

parent 0f5cc668
...@@ -170,11 +170,12 @@ static inline INT GDI_ROUND(double val) ...@@ -170,11 +170,12 @@ static inline INT GDI_ROUND(double val)
#define GET_DC_PHYSDEV(dc,func) \ #define GET_DC_PHYSDEV(dc,func) \
get_physdev_entry_point( (dc)->physDev, FIELD_OFFSET(struct gdi_dc_funcs,func)) get_physdev_entry_point( (dc)->physDev, FIELD_OFFSET(struct gdi_dc_funcs,func))
static inline PHYSDEV pop_dc_driver( DC *dc, PHYSDEV dev ) static inline PHYSDEV pop_dc_driver( DC *dc, const struct gdi_dc_funcs *funcs )
{ {
PHYSDEV *pdev = &dc->physDev; PHYSDEV dev, *pdev = &dc->physDev;
while (*pdev && *pdev != dev) pdev = &(*pdev)->next; while (*pdev && (*pdev)->funcs != funcs) pdev = &(*pdev)->next;
if (!*pdev) return NULL; if (!*pdev) return NULL;
dev = *pdev;
*pdev = dev->next; *pdev = dev->next;
return dev; return dev;
} }
......
...@@ -101,21 +101,6 @@ static inline struct path_physdev *get_path_physdev( PHYSDEV dev ) ...@@ -101,21 +101,6 @@ static inline struct path_physdev *get_path_physdev( PHYSDEV dev )
return (struct path_physdev *)dev; return (struct path_physdev *)dev;
} }
static inline void pop_path_driver( DC *dc, struct path_physdev *physdev )
{
pop_dc_driver( dc, &physdev->dev );
HeapFree( GetProcessHeap(), 0, physdev );
}
static inline struct path_physdev *find_path_physdev( DC *dc )
{
PHYSDEV dev;
for (dev = dc->physDev; dev->funcs != &null_driver; dev = dev->next)
if (dev->funcs == &path_driver) return get_path_physdev( dev );
return NULL;
}
void free_gdi_path( struct gdi_path *path ) void free_gdi_path( struct gdi_path *path )
{ {
HeapFree( GetProcessHeap(), 0, path->points ); HeapFree( GetProcessHeap(), 0, path->points );
...@@ -805,7 +790,8 @@ static BOOL pathdrv_AbortPath( PHYSDEV dev ) ...@@ -805,7 +790,8 @@ static BOOL pathdrv_AbortPath( PHYSDEV dev )
if (!dc) return FALSE; if (!dc) return FALSE;
free_gdi_path( physdev->path ); free_gdi_path( physdev->path );
pop_path_driver( dc, physdev ); pop_dc_driver( dc, &path_driver );
HeapFree( GetProcessHeap(), 0, physdev );
release_dc_ptr( dc ); release_dc_ptr( dc );
return TRUE; return TRUE;
} }
...@@ -821,7 +807,8 @@ static BOOL pathdrv_EndPath( PHYSDEV dev ) ...@@ -821,7 +807,8 @@ static BOOL pathdrv_EndPath( PHYSDEV dev )
if (!dc) return FALSE; if (!dc) return FALSE;
dc->path = physdev->path; dc->path = physdev->path;
pop_path_driver( dc, physdev ); pop_dc_driver( dc, &path_driver );
HeapFree( GetProcessHeap(), 0, physdev );
release_dc_ptr( dc ); release_dc_ptr( dc );
return TRUE; return TRUE;
} }
...@@ -874,26 +861,25 @@ BOOL PATH_SavePath( DC *dst, DC *src ) ...@@ -874,26 +861,25 @@ BOOL PATH_SavePath( DC *dst, DC *src )
BOOL PATH_RestorePath( DC *dst, DC *src ) BOOL PATH_RestorePath( DC *dst, DC *src )
{ {
struct path_physdev *physdev = find_path_physdev( dst ); PHYSDEV dev;
struct path_physdev *physdev;
if (src->path && src->path_open) if ((dev = pop_dc_driver( dst, &path_driver )))
{ {
if (!physdev) physdev = get_path_physdev( dev );
{ free_gdi_path( physdev->path );
if (!path_driver.pCreateDC( &dst->physDev, NULL, NULL, NULL, NULL )) return FALSE; HeapFree( GetProcessHeap(), 0, physdev );
physdev = get_path_physdev( find_dc_driver( dst, &path_driver )); }
}
else free_gdi_path( physdev->path );
if (src->path && src->path_open)
{
if (!path_driver.pCreateDC( &dst->physDev, NULL, NULL, NULL, NULL )) return FALSE;
physdev = get_path_physdev( find_dc_driver( dst, &path_driver ));
physdev->path = src->path; physdev->path = src->path;
src->path_open = FALSE; src->path_open = FALSE;
src->path = NULL; src->path = NULL;
} }
else if (physdev)
{
free_gdi_path( physdev->path );
pop_path_driver( dst, physdev );
}
if (dst->path) free_gdi_path( dst->path ); if (dst->path) free_gdi_path( dst->path );
dst->path = src->path; dst->path = src->path;
src->path = NULL; src->path = NULL;
......
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