mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
(!1714) dix: add per-screen pixmap destructor mechanism
Right now, extension specific pixmap destruction procedures are implemented by wrapping the ScreenRec's DestroyPixmap() proc pointer: the extensions are storing the original pointer in their private data and putting in their own one. On each call, their proc restores the original one, calls it, and switches back again. When multiple extensions doing so, they're forming a kind of daisy chain. (the same is done for lots of other procs) While that approach is looking nice and elegant on the drawing board, it's complicated, dangerous like a chainsaw and makes debugging hard, leading to pretty blurred API borders. It's even getting worse: the proc also has to do ref counting, and only destroy the pixmap if refconter reaching zero - that's all done in the individual screen drivers. Therefore, all extensions must check for refcnt == 1, in order to know when to really act. This commit introduces a simple approach for letting extension hook into the pixmap destruction safely, w/o having to care much about side effects with the call chain. Extensions now can simply register their destructor proc (and an opaque pointer) and get called back - w/o ever having to mess with the ScreenRec's internal structures. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
@@ -140,4 +140,40 @@ _X_EXPORT void dixScreenUnhookClose(ScreenPtr pScreen,
|
||||
XorgScreenCloseProcPtr func,
|
||||
void *arg);
|
||||
|
||||
/* prototype of pixmap destroy notification handler */
|
||||
typedef void (*XorgScreenPixmapDestroyProcPtr)(ScreenPtr pScreen,
|
||||
PixmapPtr pPixmap,
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* @brief register a pixmap destroy hook on the given screen
|
||||
*
|
||||
* @param pScreen pointer to the screen to register the notify hook into
|
||||
* @param func pointer to the hook function
|
||||
* @param arg opaque pointer passed to the hook
|
||||
*
|
||||
* When registration fails, the server aborts.
|
||||
* This hook is called only when the pixmap is really to be destroyed,
|
||||
* (unlike ScreenRec->DestroyPixmap())
|
||||
*
|
||||
**/
|
||||
_X_EXPORT void dixScreenHookPixmapDestroy(ScreenPtr pScreen,
|
||||
XorgScreenPixmapDestroyProcPtr func,
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* @brief unregister a pixmap destroy notify hook on the given screen
|
||||
*
|
||||
* @param pScreen pointer to the screen to unregister the hook from
|
||||
* @param func pointer to the hook function
|
||||
* @param arg opaque pointer passed to the destructor
|
||||
*
|
||||
* @see dixScreenHookClose
|
||||
*
|
||||
* Unregister a screen close notify hook registered via @ref dixScreenHookPixmapDestroy
|
||||
**/
|
||||
_X_EXPORT void dixScreenUnhookPixmapDestroy(ScreenPtr pScreen,
|
||||
XorgScreenPixmapDestroyProcPtr func,
|
||||
void *arg);
|
||||
|
||||
#endif /* DIX_SCREEN_HOOKS_H */
|
||||
|
||||
Reference in New Issue
Block a user