Commit e94d3b4e authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Add a priority mechanism for pushing drivers on the stack in a defined order.

parent 03c75b9c
...@@ -545,7 +545,7 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc ) ...@@ -545,7 +545,7 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
HGDIOBJ ret; HGDIOBJ ret;
BITMAPOBJ *bitmap; BITMAPOBJ *bitmap;
DC *dc; DC *dc;
PHYSDEV physdev = NULL, old_physdev = NULL, pathdev = NULL; PHYSDEV physdev = NULL, old_physdev = NULL;
if (!(dc = get_dc_ptr( hdc ))) return 0; if (!(dc = get_dc_ptr( hdc ))) return 0;
...@@ -571,11 +571,7 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc ) ...@@ -571,11 +571,7 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
goto done; goto done;
} }
if (dc->physDev->funcs == &path_driver) pathdev = pop_dc_driver( &dc->physDev ); if (dc->dibdrv) old_physdev = pop_dc_driver( dc, dc->dibdrv );
old_physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
if(old_physdev == dc->dibdrv)
old_physdev = pop_dc_driver( &dc->physDev );
physdev = GET_DC_PHYSDEV( dc, pSelectBitmap ); physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
if (physdev->funcs == &null_driver) if (physdev->funcs == &null_driver)
...@@ -618,12 +614,9 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc ) ...@@ -618,12 +614,9 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
done: done:
if(!ret) if(!ret)
{ {
if (physdev && physdev == dc->dibdrv) if (physdev && physdev == dc->dibdrv) pop_dc_driver( dc, dc->dibdrv );
pop_dc_driver( &dc->physDev ); if (old_physdev) push_dc_driver( &dc->physDev, old_physdev, old_physdev->funcs );
if (old_physdev && old_physdev == dc->dibdrv)
push_dc_driver( &dc->physDev, old_physdev, old_physdev->funcs );
} }
if (pathdev) push_dc_driver( &dc->physDev, pathdev, pathdev->funcs );
release_dc_ptr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
......
...@@ -156,7 +156,8 @@ void free_dc_ptr( DC *dc ) ...@@ -156,7 +156,8 @@ void free_dc_ptr( DC *dc )
while (dc->physDev != &dc->nulldrv) while (dc->physDev != &dc->nulldrv)
{ {
PHYSDEV physdev = pop_dc_driver( &dc->physDev ); PHYSDEV physdev = dc->physDev;
dc->physDev = physdev->next;
physdev->funcs->pDeleteDC( physdev ); physdev->funcs->pDeleteDC( physdev );
if (physdev == dc->dibdrv) dc->dibdrv = NULL; if (physdev == dc->dibdrv) dc->dibdrv = NULL;
} }
......
...@@ -1570,7 +1570,7 @@ static HGDIOBJ DIB_SelectObject( HGDIOBJ handle, HDC hdc ) ...@@ -1570,7 +1570,7 @@ static HGDIOBJ DIB_SelectObject( HGDIOBJ handle, HDC hdc )
HGDIOBJ ret; HGDIOBJ ret;
BITMAPOBJ *bitmap; BITMAPOBJ *bitmap;
DC *dc; DC *dc;
PHYSDEV physdev = NULL, old_physdev = NULL, pathdev = NULL; PHYSDEV physdev = NULL, old_physdev = NULL;
if (!(dc = get_dc_ptr( hdc ))) return 0; if (!(dc = get_dc_ptr( hdc ))) return 0;
...@@ -1596,8 +1596,6 @@ static HGDIOBJ DIB_SelectObject( HGDIOBJ handle, HDC hdc ) ...@@ -1596,8 +1596,6 @@ static HGDIOBJ DIB_SelectObject( HGDIOBJ handle, HDC hdc )
goto done; goto done;
} }
if (dc->physDev->funcs == &path_driver) pathdev = pop_dc_driver( &dc->physDev );
old_physdev = GET_DC_PHYSDEV( dc, pSelectBitmap ); old_physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
physdev = dc->dibdrv; physdev = dc->dibdrv;
if (old_physdev != dc->dibdrv) if (old_physdev != dc->dibdrv)
...@@ -1633,9 +1631,8 @@ static HGDIOBJ DIB_SelectObject( HGDIOBJ handle, HDC hdc ) ...@@ -1633,9 +1631,8 @@ static HGDIOBJ DIB_SelectObject( HGDIOBJ handle, HDC hdc )
done: done:
if(!ret) if(!ret)
{ {
if (old_physdev && old_physdev != dc->dibdrv) pop_dc_driver( &dc->physDev ); if (old_physdev && old_physdev != dc->dibdrv) pop_dc_driver( dc, dc->dibdrv );
} }
if (pathdev) push_dc_driver( &dc->physDev, pathdev, pathdev->funcs );
release_dc_ptr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
......
...@@ -742,4 +742,6 @@ const struct gdi_dc_funcs dib_driver = ...@@ -742,4 +742,6 @@ const struct gdi_dc_funcs dib_driver =
dibdrv_wglShareLists, /* pwglShareLists */ dibdrv_wglShareLists, /* pwglShareLists */
dibdrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */ dibdrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
dibdrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */ dibdrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
GDI_PRIORITY_DIB_DRV /* priority */
}; };
...@@ -875,6 +875,8 @@ const struct gdi_dc_funcs null_driver = ...@@ -875,6 +875,8 @@ const struct gdi_dc_funcs null_driver =
nulldrv_wglShareLists, /* pwglShareLists */ nulldrv_wglShareLists, /* pwglShareLists */
nulldrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */ nulldrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
nulldrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */ nulldrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
GDI_PRIORITY_NULL_DRV /* priority */
}; };
......
...@@ -169,7 +169,20 @@ static const struct gdi_dc_funcs EMFDRV_Funcs = ...@@ -169,7 +169,20 @@ static const struct gdi_dc_funcs EMFDRV_Funcs =
EMFDRV_StrokePath, /* pStrokePath */ EMFDRV_StrokePath, /* pStrokePath */
NULL, /* pSwapBuffers */ NULL, /* pSwapBuffers */
NULL, /* pUnrealizePalette */ NULL, /* pUnrealizePalette */
EMFDRV_WidenPath /* pWidenPath */ EMFDRV_WidenPath, /* pWidenPath */
NULL, /* pwglCopyContext */
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglDeleteContext */
NULL, /* pwglGetPbufferDCARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* pwglShareLists */
NULL, /* pwglUseFontBitmapsA */
NULL, /* pwglUseFontBitmapsW */
GDI_PRIORITY_GRAPHICS_DRV /* priority */
}; };
......
...@@ -7874,7 +7874,19 @@ static const struct gdi_dc_funcs freetype_funcs = ...@@ -7874,7 +7874,19 @@ static const struct gdi_dc_funcs freetype_funcs =
NULL, /* pSwapBuffers */ NULL, /* pSwapBuffers */
NULL, /* pUnrealizePalette */ NULL, /* pUnrealizePalette */
NULL, /* pWidenPath */ NULL, /* pWidenPath */
/* OpenGL not supported */ NULL, /* pwglCopyContext */
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglDeleteContext */
NULL, /* pwglGetPbufferDCARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* pwglShareLists */
NULL, /* pwglUseFontBitmapsA */
NULL, /* pwglUseFontBitmapsW */
GDI_PRIORITY_FONT_DRV /* priority */
}; };
#else /* HAVE_FREETYPE */ #else /* HAVE_FREETYPE */
......
...@@ -170,6 +170,15 @@ static inline INT GDI_ROUND(double val) ...@@ -170,6 +170,15 @@ 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 )
{
PHYSDEV *pdev = &dc->physDev;
while (*pdev && *pdev != dev) pdev = &(*pdev)->next;
if (!*pdev) return NULL;
*pdev = dev->next;
return dev;
}
/* bitmap object */ /* bitmap object */
typedef struct tagBITMAPOBJ typedef struct tagBITMAPOBJ
......
...@@ -232,7 +232,20 @@ static const struct gdi_dc_funcs MFDRV_Funcs = ...@@ -232,7 +232,20 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
MFDRV_StrokePath, /* pStrokePath */ MFDRV_StrokePath, /* pStrokePath */
NULL, /* pSwapBuffers */ NULL, /* pSwapBuffers */
NULL, /* pUnrealizePalette */ NULL, /* pUnrealizePalette */
MFDRV_WidenPath /* pWidenPath */ MFDRV_WidenPath, /* pWidenPath */
NULL, /* pwglCopyContext */
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglDeleteContext */
NULL, /* pwglGetPbufferDCARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* pwglShareLists */
NULL, /* pwglUseFontBitmapsA */
NULL, /* pwglUseFontBitmapsW */
GDI_PRIORITY_GRAPHICS_DRV /* priority */
}; };
......
...@@ -103,9 +103,7 @@ static inline struct path_physdev *get_path_physdev( PHYSDEV dev ) ...@@ -103,9 +103,7 @@ static inline struct path_physdev *get_path_physdev( PHYSDEV dev )
static inline void pop_path_driver( DC *dc, struct path_physdev *physdev ) static inline void pop_path_driver( DC *dc, struct path_physdev *physdev )
{ {
PHYSDEV *dev = &dc->physDev; pop_dc_driver( dc, &physdev->dev );
while (*dev != &physdev->dev) dev = &(*dev)->next;
*dev = physdev->dev.next;
HeapFree( GetProcessHeap(), 0, physdev ); HeapFree( GetProcessHeap(), 0, physdev );
} }
...@@ -2369,5 +2367,17 @@ const struct gdi_dc_funcs path_driver = ...@@ -2369,5 +2367,17 @@ const struct gdi_dc_funcs path_driver =
NULL, /* pSwapBuffers */ NULL, /* pSwapBuffers */
NULL, /* pUnrealizePalette */ NULL, /* pUnrealizePalette */
NULL, /* pWidenPath */ NULL, /* pWidenPath */
/* OpenGL not supported */ NULL, /* pwglCopyContext */
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglDeleteContext */
NULL, /* pwglGetPbufferDCARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* pwglShareLists */
NULL, /* pwglUseFontBitmapsA */
NULL, /* pwglUseFontBitmapsW */
GDI_PRIORITY_PATH_DRV /* priority */
}; };
...@@ -952,7 +952,19 @@ static const struct gdi_dc_funcs psdrv_funcs = ...@@ -952,7 +952,19 @@ static const struct gdi_dc_funcs psdrv_funcs =
NULL, /* pSwapBuffers */ NULL, /* pSwapBuffers */
NULL, /* pUnrealizePalette */ NULL, /* pUnrealizePalette */
NULL, /* pWidenPath */ NULL, /* pWidenPath */
/* OpenGL not supported */ NULL, /* pwglCopyContext */
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglDeleteContext */
NULL, /* pwglGetPbufferDCARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* pwglShareLists */
NULL, /* pwglUseFontBitmapsA */
NULL, /* pwglUseFontBitmapsW */
GDI_PRIORITY_GRAPHICS_DRV /* priority */
}; };
......
...@@ -583,6 +583,7 @@ static const struct gdi_dc_funcs x11drv_funcs = ...@@ -583,6 +583,7 @@ static const struct gdi_dc_funcs x11drv_funcs =
X11DRV_wglShareLists, /* pwglShareLists */ X11DRV_wglShareLists, /* pwglShareLists */
X11DRV_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */ X11DRV_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
X11DRV_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */ X11DRV_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
GDI_PRIORITY_GRAPHICS_DRV /* priority */
}; };
......
...@@ -2780,7 +2780,19 @@ static const struct gdi_dc_funcs xrender_funcs = ...@@ -2780,7 +2780,19 @@ static const struct gdi_dc_funcs xrender_funcs =
NULL, /* pSwapBuffers */ NULL, /* pSwapBuffers */
NULL, /* pUnrealizePalette */ NULL, /* pUnrealizePalette */
NULL, /* pWidenPath */ NULL, /* pWidenPath */
/* OpenGL not supported */ NULL, /* pwglCopyContext */
NULL, /* pwglCreateContext */
NULL, /* pwglCreateContextAttribsARB */
NULL, /* pwglDeleteContext */
NULL, /* pwglGetPbufferDCARB */
NULL, /* pwglGetProcAddress */
NULL, /* pwglMakeContextCurrentARB */
NULL, /* pwglMakeCurrent */
NULL, /* pwglSetPixelFormatWINE */
NULL, /* pwglShareLists */
NULL, /* pwglUseFontBitmapsA */
NULL, /* pwglUseFontBitmapsW */
GDI_PRIORITY_GRAPHICS_DRV + 10 /* priority */
}; };
#else /* SONAME_LIBXRENDER */ #else /* SONAME_LIBXRENDER */
......
...@@ -196,8 +196,6 @@ struct gdi_dc_funcs ...@@ -196,8 +196,6 @@ struct gdi_dc_funcs
BOOL (*pSwapBuffers)(PHYSDEV); BOOL (*pSwapBuffers)(PHYSDEV);
BOOL (*pUnrealizePalette)(HPALETTE); BOOL (*pUnrealizePalette)(HPALETTE);
BOOL (*pWidenPath)(PHYSDEV); BOOL (*pWidenPath)(PHYSDEV);
/* OpenGL32 */
BOOL (*pwglCopyContext)(HGLRC,HGLRC,UINT); BOOL (*pwglCopyContext)(HGLRC,HGLRC,UINT);
HGLRC (*pwglCreateContext)(PHYSDEV); HGLRC (*pwglCreateContext)(PHYSDEV);
HGLRC (*pwglCreateContextAttribsARB)(PHYSDEV,HGLRC,const int*); HGLRC (*pwglCreateContextAttribsARB)(PHYSDEV,HGLRC,const int*);
...@@ -210,10 +208,19 @@ struct gdi_dc_funcs ...@@ -210,10 +208,19 @@ struct gdi_dc_funcs
BOOL (*pwglShareLists)(HGLRC,HGLRC); BOOL (*pwglShareLists)(HGLRC,HGLRC);
BOOL (*pwglUseFontBitmapsA)(PHYSDEV,DWORD,DWORD,DWORD); BOOL (*pwglUseFontBitmapsA)(PHYSDEV,DWORD,DWORD,DWORD);
BOOL (*pwglUseFontBitmapsW)(PHYSDEV,DWORD,DWORD,DWORD); BOOL (*pwglUseFontBitmapsW)(PHYSDEV,DWORD,DWORD,DWORD);
/* priority order for the driver on the stack */
UINT priority;
}; };
/* increment this when you change the DC function table */ /* increment this when you change the DC function table */
#define WINE_GDI_DRIVER_VERSION 26 #define WINE_GDI_DRIVER_VERSION 27
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */
#define GDI_PRIORITY_FONT_DRV 100 /* any font driver */
#define GDI_PRIORITY_GRAPHICS_DRV 200 /* any graphics driver */
#define GDI_PRIORITY_DIB_DRV 300 /* the DIB driver */
#define GDI_PRIORITY_PATH_DRV 400 /* the path driver */
static inline PHYSDEV get_physdev_entry_point( PHYSDEV dev, size_t offset ) static inline PHYSDEV get_physdev_entry_point( PHYSDEV dev, size_t offset )
{ {
...@@ -226,17 +233,11 @@ static inline PHYSDEV get_physdev_entry_point( PHYSDEV dev, size_t offset ) ...@@ -226,17 +233,11 @@ static inline PHYSDEV get_physdev_entry_point( PHYSDEV dev, size_t offset )
static inline void push_dc_driver( PHYSDEV *dev, PHYSDEV physdev, const struct gdi_dc_funcs *funcs ) static inline void push_dc_driver( PHYSDEV *dev, PHYSDEV physdev, const struct gdi_dc_funcs *funcs )
{ {
while ((*dev)->funcs->priority > funcs->priority) dev = &(*dev)->next;
physdev->funcs = funcs; physdev->funcs = funcs;
physdev->next = *dev; physdev->next = *dev;
physdev->hdc = (*dev)->hdc; physdev->hdc = (*dev)->hdc;
*dev = physdev; *dev = physdev;
} }
static inline PHYSDEV pop_dc_driver( PHYSDEV *dev )
{
PHYSDEV ret = *dev;
*dev = ret->next;
return ret;
}
#endif /* __WINE_WINE_GDI_DRIVER_H */ #endif /* __WINE_WINE_GDI_DRIVER_H */
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