glamor: use PixmapDestroy hook
Wrapping ScreenRec's function pointers is problematic for many reasons, so use the new pixmap destroy notify hook instead. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
f39bbe58d6
commit
cece84fa93
|
@ -616,6 +616,11 @@ glamor_setup_formats(ScreenPtr screen)
|
|||
glamor_priv->cbcr_format.texture_only = FALSE;
|
||||
}
|
||||
|
||||
static void glamor_pixmap_destroy(CallbackListPtr *pcbl, ScreenPtr pScreen, PixmapPtr pPixmap)
|
||||
{
|
||||
glamor_pixmap_destroy_fbo(pPixmap);
|
||||
}
|
||||
|
||||
/* This function is used to free the glamor private screen's
|
||||
* resources. If the DDX driver is not set GLAMOR_USE_SCREEN,
|
||||
* then, DDX need to call this function at proper stage, if
|
||||
|
@ -651,7 +656,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate screen private\n",
|
||||
screen->myNum);
|
||||
goto free_glamor_private;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
glamor_set_screen_private(screen, glamor_priv);
|
||||
|
@ -661,7 +666,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate pixmap private\n",
|
||||
screen->myNum);
|
||||
goto free_glamor_private;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!dixRegisterPrivateKey(&glamor_gc_private_key, PRIVATE_GC,
|
||||
|
@ -669,12 +674,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate gc private\n",
|
||||
screen->myNum);
|
||||
goto free_glamor_private;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
glamor_priv->saved_procs.destroy_pixmap = screen->DestroyPixmap;
|
||||
screen->DestroyPixmap = glamor_destroy_pixmap;
|
||||
|
||||
/* If we are using egl screen, call egl screen init to
|
||||
* register correct close screen function. */
|
||||
if (flags & GLAMOR_USE_EGL_SCREEN) {
|
||||
|
@ -895,14 +897,11 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
glamor_priv->screen = screen;
|
||||
|
||||
dixScreenHookClose(screen, glamor_close_screen);
|
||||
dixScreenHookPixmapDestroy(screen, glamor_pixmap_destroy);
|
||||
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
/* Restore default DestroyPixmap handler */
|
||||
screen->DestroyPixmap = glamor_priv->saved_procs.destroy_pixmap;
|
||||
|
||||
free_glamor_private:
|
||||
free(glamor_priv);
|
||||
glamor_set_screen_private(screen, NULL);
|
||||
return FALSE;
|
||||
|
@ -932,10 +931,10 @@ static void glamor_close_screen(CallbackListPtr *pcbl, ScreenPtr screen, void *u
|
|||
glamor_set_glvnd_vendor(screen, NULL);
|
||||
|
||||
dixScreenUnhookClose(screen, glamor_close_screen);
|
||||
dixScreenUnhookPixmapDestroy(screen, glamor_pixmap_destroy);
|
||||
|
||||
screen->CreateGC = glamor_priv->saved_procs.create_gc;
|
||||
screen->CreatePixmap = glamor_priv->saved_procs.create_pixmap;
|
||||
screen->DestroyPixmap = glamor_priv->saved_procs.destroy_pixmap;
|
||||
screen->GetSpans = glamor_priv->saved_procs.get_spans;
|
||||
screen->ChangeWindowAttributes =
|
||||
glamor_priv->saved_procs.change_window_attributes;
|
||||
|
|
|
@ -60,7 +60,6 @@ struct glamor_egl_screen_private {
|
|||
int dmabuf_capable;
|
||||
Bool force_vendor; /* if GLVND vendor is forced from options */
|
||||
|
||||
DestroyPixmapProcPtr saved_destroy_pixmap;
|
||||
xf86FreeScreenProc *saved_free_screen;
|
||||
};
|
||||
|
||||
|
@ -744,35 +743,22 @@ glamor_egl_get_driver_name(ScreenPtr screen)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
glamor_egl_destroy_pixmap(PixmapPtr pixmap)
|
||||
static void glamor_egl_pixmap_destroy(CallbackListPtr *pcbl, ScreenPtr pScreen, PixmapPtr pixmap)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||
struct glamor_egl_screen_private *glamor_egl =
|
||||
glamor_egl_get_screen_private(scrn);
|
||||
Bool ret = TRUE;
|
||||
|
||||
if (pixmap->refcnt == 1) {
|
||||
struct glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
|
||||
BUG_RETURN_VAL(!pixmap_priv, FALSE);
|
||||
BUG_RETURN(!pixmap_priv);
|
||||
|
||||
if (pixmap_priv->image)
|
||||
eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
|
||||
}
|
||||
|
||||
screen->DestroyPixmap = glamor_egl->saved_destroy_pixmap;
|
||||
if (screen->DestroyPixmap)
|
||||
ret = screen->DestroyPixmap(pixmap);
|
||||
glamor_egl->saved_destroy_pixmap = screen->DestroyPixmap;
|
||||
screen->DestroyPixmap = glamor_egl_destroy_pixmap;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
|
||||
{
|
||||
|
@ -810,12 +796,13 @@ static void glamor_egl_close_screen(CallbackListPtr *pcbl, ScreenPtr screen, voi
|
|||
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
|
||||
BUG_RETURN_VAL(!pixmap_priv, FALSE);
|
||||
BUG_RETURN(!pixmap_priv);
|
||||
|
||||
eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
|
||||
pixmap_priv->image = NULL;
|
||||
|
||||
dixScreenUnhookClose(screen, glamor_egl_close_screen);
|
||||
dixScreenUnhookPixmapDestroy(screen, glamor_egl_pixmap_destroy);
|
||||
}
|
||||
|
||||
#ifdef DRI3
|
||||
|
@ -896,9 +883,7 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
|
|||
const char *gbm_backend_name;
|
||||
|
||||
dixScreenHookClose(screen, glamor_egl_close_screen);
|
||||
|
||||
glamor_egl->saved_destroy_pixmap = screen->DestroyPixmap;
|
||||
screen->DestroyPixmap = glamor_egl_destroy_pixmap;
|
||||
dixScreenHookPixmapDestroy(screen, glamor_egl_pixmap_destroy);
|
||||
|
||||
glamor_ctx->ctx = glamor_egl->context;
|
||||
glamor_ctx->display = glamor_egl->display;
|
||||
|
|
|
@ -217,7 +217,6 @@ struct glamor_format {
|
|||
struct glamor_saved_procs {
|
||||
CreateGCProcPtr create_gc;
|
||||
CreatePixmapProcPtr create_pixmap;
|
||||
DestroyPixmapProcPtr destroy_pixmap;
|
||||
GetSpansProcPtr get_spans;
|
||||
GetImageProcPtr get_image;
|
||||
CompositeProcPtr composite;
|
||||
|
|
Loading…
Reference in New Issue