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

This commit is contained in:
Alexandre Julliard 2012-05-08 12:16:05 +02:00
parent 03c75b9cf6
commit e94d3b4e08
14 changed files with 114 additions and 36 deletions

View File

@ -545,7 +545,7 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
HGDIOBJ ret;
BITMAPOBJ *bitmap;
DC *dc;
PHYSDEV physdev = NULL, old_physdev = NULL, pathdev = NULL;
PHYSDEV physdev = NULL, old_physdev = NULL;
if (!(dc = get_dc_ptr( hdc ))) return 0;
@ -571,11 +571,7 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
goto done;
}
if (dc->physDev->funcs == &path_driver) pathdev = pop_dc_driver( &dc->physDev );
old_physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
if(old_physdev == dc->dibdrv)
old_physdev = pop_dc_driver( &dc->physDev );
if (dc->dibdrv) old_physdev = pop_dc_driver( dc, dc->dibdrv );
physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
if (physdev->funcs == &null_driver)
@ -618,12 +614,9 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
done:
if(!ret)
{
if (physdev && physdev == dc->dibdrv)
pop_dc_driver( &dc->physDev );
if (old_physdev && old_physdev == dc->dibdrv)
push_dc_driver( &dc->physDev, old_physdev, old_physdev->funcs );
if (physdev && physdev == dc->dibdrv) pop_dc_driver( dc, dc->dibdrv );
if (old_physdev) push_dc_driver( &dc->physDev, old_physdev, old_physdev->funcs );
}
if (pathdev) push_dc_driver( &dc->physDev, pathdev, pathdev->funcs );
release_dc_ptr( dc );
return ret;
}

View File

@ -156,7 +156,8 @@ void free_dc_ptr( DC *dc )
while (dc->physDev != &dc->nulldrv)
{
PHYSDEV physdev = pop_dc_driver( &dc->physDev );
PHYSDEV physdev = dc->physDev;
dc->physDev = physdev->next;
physdev->funcs->pDeleteDC( physdev );
if (physdev == dc->dibdrv) dc->dibdrv = NULL;
}

View File

@ -1570,7 +1570,7 @@ static HGDIOBJ DIB_SelectObject( HGDIOBJ handle, HDC hdc )
HGDIOBJ ret;
BITMAPOBJ *bitmap;
DC *dc;
PHYSDEV physdev = NULL, old_physdev = NULL, pathdev = NULL;
PHYSDEV physdev = NULL, old_physdev = NULL;
if (!(dc = get_dc_ptr( hdc ))) return 0;
@ -1596,8 +1596,6 @@ static HGDIOBJ DIB_SelectObject( HGDIOBJ handle, HDC hdc )
goto done;
}
if (dc->physDev->funcs == &path_driver) pathdev = pop_dc_driver( &dc->physDev );
old_physdev = GET_DC_PHYSDEV( dc, pSelectBitmap );
physdev = dc->dibdrv;
if (old_physdev != dc->dibdrv)
@ -1633,9 +1631,8 @@ static HGDIOBJ DIB_SelectObject( HGDIOBJ handle, HDC hdc )
done:
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 );
return ret;
}

View File

@ -742,4 +742,6 @@ const struct gdi_dc_funcs dib_driver =
dibdrv_wglShareLists, /* pwglShareLists */
dibdrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
dibdrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
GDI_PRIORITY_DIB_DRV /* priority */
};

View File

@ -875,6 +875,8 @@ const struct gdi_dc_funcs null_driver =
nulldrv_wglShareLists, /* pwglShareLists */
nulldrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
nulldrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
GDI_PRIORITY_NULL_DRV /* priority */
};

View File

@ -169,7 +169,20 @@ static const struct gdi_dc_funcs EMFDRV_Funcs =
EMFDRV_StrokePath, /* pStrokePath */
NULL, /* pSwapBuffers */
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 */
};

View File

@ -7874,7 +7874,19 @@ static const struct gdi_dc_funcs freetype_funcs =
NULL, /* pSwapBuffers */
NULL, /* pUnrealizePalette */
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 */

View File

@ -170,6 +170,15 @@ 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 )
{
PHYSDEV *pdev = &dc->physDev;
while (*pdev && *pdev != dev) pdev = &(*pdev)->next;
if (!*pdev) return NULL;
*pdev = dev->next;
return dev;
}
/* bitmap object */
typedef struct tagBITMAPOBJ

View File

@ -232,7 +232,20 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
MFDRV_StrokePath, /* pStrokePath */
NULL, /* pSwapBuffers */
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 */
};

View File

@ -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 )
{
PHYSDEV *dev = &dc->physDev;
while (*dev != &physdev->dev) dev = &(*dev)->next;
*dev = physdev->dev.next;
pop_dc_driver( dc, &physdev->dev );
HeapFree( GetProcessHeap(), 0, physdev );
}
@ -2369,5 +2367,17 @@ const struct gdi_dc_funcs path_driver =
NULL, /* pSwapBuffers */
NULL, /* pUnrealizePalette */
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 */
};

View File

@ -952,7 +952,19 @@ static const struct gdi_dc_funcs psdrv_funcs =
NULL, /* pSwapBuffers */
NULL, /* pUnrealizePalette */
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 */
};

View File

@ -583,6 +583,7 @@ static const struct gdi_dc_funcs x11drv_funcs =
X11DRV_wglShareLists, /* pwglShareLists */
X11DRV_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
X11DRV_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
GDI_PRIORITY_GRAPHICS_DRV /* priority */
};

View File

@ -2780,7 +2780,19 @@ static const struct gdi_dc_funcs xrender_funcs =
NULL, /* pSwapBuffers */
NULL, /* pUnrealizePalette */
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 */

View File

@ -196,8 +196,6 @@ struct gdi_dc_funcs
BOOL (*pSwapBuffers)(PHYSDEV);
BOOL (*pUnrealizePalette)(HPALETTE);
BOOL (*pWidenPath)(PHYSDEV);
/* OpenGL32 */
BOOL (*pwglCopyContext)(HGLRC,HGLRC,UINT);
HGLRC (*pwglCreateContext)(PHYSDEV);
HGLRC (*pwglCreateContextAttribsARB)(PHYSDEV,HGLRC,const int*);
@ -210,10 +208,19 @@ struct gdi_dc_funcs
BOOL (*pwglShareLists)(HGLRC,HGLRC);
BOOL (*pwglUseFontBitmapsA)(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 */
#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 )
{
@ -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 )
{
while ((*dev)->funcs->priority > funcs->priority) dev = &(*dev)->next;
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 */