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

This commit is contained in:
Alexandre Julliard 2012-08-21 12:59:18 +02:00
parent 0f5cc668ba
commit bf528c5e9c
2 changed files with 20 additions and 33 deletions

View File

@ -170,11 +170,12 @@ static inline INT GDI_ROUND(double val)
#define GET_DC_PHYSDEV(dc,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;
while (*pdev && *pdev != dev) pdev = &(*pdev)->next;
PHYSDEV dev, *pdev = &dc->physDev;
while (*pdev && (*pdev)->funcs != funcs) pdev = &(*pdev)->next;
if (!*pdev) return NULL;
dev = *pdev;
*pdev = dev->next;
return dev;
}

View File

@ -101,21 +101,6 @@ static inline struct path_physdev *get_path_physdev( 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 )
{
HeapFree( GetProcessHeap(), 0, path->points );
@ -805,7 +790,8 @@ static BOOL pathdrv_AbortPath( PHYSDEV dev )
if (!dc) return FALSE;
free_gdi_path( physdev->path );
pop_path_driver( dc, physdev );
pop_dc_driver( dc, &path_driver );
HeapFree( GetProcessHeap(), 0, physdev );
release_dc_ptr( dc );
return TRUE;
}
@ -821,7 +807,8 @@ static BOOL pathdrv_EndPath( PHYSDEV dev )
if (!dc) return FALSE;
dc->path = physdev->path;
pop_path_driver( dc, physdev );
pop_dc_driver( dc, &path_driver );
HeapFree( GetProcessHeap(), 0, physdev );
release_dc_ptr( dc );
return TRUE;
}
@ -874,26 +861,25 @@ BOOL PATH_SavePath( 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 ((dev = pop_dc_driver( dst, &path_driver )))
{
physdev = get_path_physdev( dev );
free_gdi_path( physdev->path );
HeapFree( GetProcessHeap(), 0, physdev );
}
if (src->path && src->path_open)
{
if (!physdev)
{
if (!path_driver.pCreateDC( &dst->physDev, NULL, NULL, NULL, NULL )) return FALSE;
physdev = get_path_physdev( find_dc_driver( dst, &path_driver ));
}
else free_gdi_path( physdev->path );
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;
src->path_open = FALSE;
src->path = NULL;
}
else if (physdev)
{
free_gdi_path( physdev->path );
pop_path_driver( dst, physdev );
}
if (dst->path) free_gdi_path( dst->path );
dst->path = src->path;
src->path = NULL;