diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index 3a4cacac92..95a45ffbff 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -703,12 +703,12 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc ) old_physdev = GET_DC_PHYSDEV( dc, pSelectBitmap ); if(old_physdev == &dc->dibdrv.dev) - pop_dc_driver( dc, old_physdev ); + old_physdev = pop_dc_driver( &dc->physDev ); if(bitmap->dib) { physdev = &dc->dibdrv.dev; - push_dc_driver( dc, physdev, physdev->funcs ); + push_dc_driver( &dc->physDev, physdev, physdev->funcs ); } else physdev = GET_DC_PHYSDEV( dc, pSelectBitmap ); @@ -742,8 +742,8 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc ) done: if(!ret) { - if(physdev == &dc->dibdrv.dev) pop_dc_driver( dc, physdev ); - if(old_physdev == &dc->dibdrv.dev) push_dc_driver( dc, old_physdev, old_physdev->funcs ); + if(physdev == &dc->dibdrv.dev) pop_dc_driver( &dc->physDev ); + if(old_physdev == &dc->dibdrv.dev) push_dc_driver( &dc->physDev, old_physdev, old_physdev->funcs ); } release_dc_ptr( dc ); return ret; diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 286fa0e9a2..5ab054a623 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -183,8 +183,7 @@ void free_dc_ptr( DC *dc ) while (dc->physDev != &dc->nulldrv) { - PHYSDEV physdev = dc->physDev; - pop_dc_driver( dc, physdev ); + PHYSDEV physdev = pop_dc_driver( &dc->physDev ); physdev->funcs->pDeleteDC( physdev ); } free_gdi_handle( dc->hSelf ); @@ -247,33 +246,6 @@ void update_dc( DC *dc ) } -/*********************************************************************** - * push_dc_driver - * - * Push a driver on top of the DC driver stack. - */ -void push_dc_driver( DC * dc, PHYSDEV physdev, const DC_FUNCTIONS *funcs ) -{ - physdev->funcs = funcs; - physdev->next = dc->physDev; - physdev->hdc = dc->hSelf; - dc->physDev = physdev; -} - - -/*********************************************************************** - * pop_dc_driver - * - * Pop the top driver from the DC driver stack. - */ -void pop_dc_driver( DC * dc, PHYSDEV physdev ) -{ - assert( physdev == dc->physDev ); - assert( physdev != &dc->nulldrv ); - dc->physDev = physdev->next; -} - - /*********************************************************************** * DC_DeleteObject */ @@ -662,7 +634,7 @@ HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output, WARN("creation aborted by device\n" ); goto error; } - push_dc_driver( dc, physdev, funcs ); + push_dc_driver( &dc->physDev, physdev, funcs ); } dc->vis_rect.left = 0; @@ -786,7 +758,7 @@ HDC WINAPI CreateCompatibleDC( HDC hdc ) WARN("creation aborted by device\n"); goto error; } - push_dc_driver( dc, physDev, funcs ); + push_dc_driver( &dc->physDev, physDev, funcs ); } DC_InitDC( dc ); release_dc_ptr( dc ); diff --git a/dlls/gdi32/enhmfdrv/init.c b/dlls/gdi32/enhmfdrv/init.c index 9f808544c4..558ebd1a53 100644 --- a/dlls/gdi32/enhmfdrv/init.c +++ b/dlls/gdi32/enhmfdrv/init.c @@ -331,7 +331,7 @@ HDC WINAPI CreateEnhMetaFileW( return 0; } - push_dc_driver( dc, &physDev->dev, &EMFDRV_Funcs ); + push_dc_driver( &dc->physDev, &physDev->dev, &EMFDRV_Funcs ); physDev->handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, HANDLE_LIST_INC * sizeof(physDev->handles[0])); physDev->handles_size = HANDLE_LIST_INC; diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index c4ed75ae1b..2e12f4d223 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -330,8 +330,6 @@ extern void free_dc_ptr( DC *dc ) DECLSPEC_HIDDEN; extern DC *get_dc_ptr( HDC hdc ) DECLSPEC_HIDDEN; extern void release_dc_ptr( DC *dc ) DECLSPEC_HIDDEN; extern void update_dc( DC *dc ) DECLSPEC_HIDDEN; -extern void push_dc_driver( DC * dc, PHYSDEV physdev, const DC_FUNCTIONS *funcs ) DECLSPEC_HIDDEN; -extern void pop_dc_driver( DC * dc, PHYSDEV physdev ) DECLSPEC_HIDDEN; extern void DC_InitDC( DC * dc ) DECLSPEC_HIDDEN; extern void DC_UpdateXforms( DC * dc ) DECLSPEC_HIDDEN; diff --git a/dlls/gdi32/mfdrv/init.c b/dlls/gdi32/mfdrv/init.c index dca30db34d..421edef627 100644 --- a/dlls/gdi32/mfdrv/init.c +++ b/dlls/gdi32/mfdrv/init.c @@ -224,7 +224,7 @@ static DC *MFDRV_AllocMetaFile(void) return NULL; } - push_dc_driver( dc, &physDev->dev, &MFDRV_Funcs ); + push_dc_driver( &dc->physDev, &physDev->dev, &MFDRV_Funcs ); physDev->handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, HANDLE_LIST_INC * sizeof(physDev->handles[0])); physDev->handles_size = HANDLE_LIST_INC; diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 36a265ab74..caf4d0dfd7 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -199,4 +199,19 @@ static inline PHYSDEV get_physdev_entry_point( PHYSDEV dev, size_t offset ) #define GET_NEXT_PHYSDEV(dev,func) \ get_physdev_entry_point( (dev)->next, FIELD_OFFSET(struct gdi_dc_funcs,func)) +static inline void push_dc_driver( PHYSDEV *dev, PHYSDEV physdev, const struct gdi_dc_funcs *funcs ) +{ + physdev->funcs = funcs; + physdev->next = *dev; + physdev->hdc = (*dev)->hdc; + *dev = physdev; +} + +static inline PHYSDEV pop_dc_driver( PHYSDEV *dev ) +{ + PHYSDEV ret = *dev; + *dev = ret->next; + return ret; +} + #endif /* __WINE_WINE_GDI_DRIVER_H */