(!1714) 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
							
								
									c248346e78
								
							
						
					
					
						commit
						dd04d3fe5c
					
				|  | @ -604,6 +604,11 @@ glamor_setup_formats(ScreenPtr screen) | |||
|     glamor_priv->cbcr_format.texture_only = FALSE; | ||||
| } | ||||
| 
 | ||||
| static void glamor_pixmap_destroy(ScreenPtr pScreen, PixmapPtr pPixmap, void *arg) | ||||
| { | ||||
|     glamor_pixmap_destroy_fbo(pPixmap); | ||||
| } | ||||
| 
 | ||||
| /** Set up glamor for an already-configured GL context. */ | ||||
| Bool | ||||
| glamor_init(ScreenPtr screen, unsigned int flags) | ||||
|  | @ -652,8 +657,7 @@ glamor_init(ScreenPtr screen, unsigned int flags) | |||
|     glamor_priv->saved_procs.close_screen = screen->CloseScreen; | ||||
|     screen->CloseScreen = glamor_close_screen; | ||||
| 
 | ||||
|     glamor_priv->saved_procs.destroy_pixmap = screen->DestroyPixmap; | ||||
|     screen->DestroyPixmap = glamor_destroy_pixmap; | ||||
|     dixScreenHookPixmapDestroy(screen, glamor_pixmap_destroy, NULL); | ||||
| 
 | ||||
|     /* If we are using egl screen, call egl screen init to
 | ||||
|      * register correct close screen function. */ | ||||
|  | @ -879,7 +883,7 @@ glamor_init(ScreenPtr screen, unsigned int flags) | |||
|  fail: | ||||
|     /* Restore default CloseScreen and DestroyPixmap handlers */ | ||||
|     screen->CloseScreen = glamor_priv->saved_procs.close_screen; | ||||
|     screen->DestroyPixmap = glamor_priv->saved_procs.destroy_pixmap; | ||||
|     dixScreenUnhookPixmapDestroy(screen, glamor_pixmap_destroy, NULL); | ||||
| 
 | ||||
|  free_glamor_private: | ||||
|     free(glamor_priv); | ||||
|  | @ -913,9 +917,10 @@ glamor_close_screen(ScreenPtr screen) | |||
|     glamor_set_glvnd_vendor(screen, NULL); | ||||
|     screen->CloseScreen = glamor_priv->saved_procs.close_screen; | ||||
| 
 | ||||
|     dixScreenUnhookPixmapDestroy(screen, glamor_pixmap_destroy, NULL); | ||||
| 
 | ||||
|     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; | ||||
|  |  | |||
|  | @ -62,7 +62,6 @@ struct glamor_egl_screen_private { | |||
|     Bool force_vendor; /* if GLVND vendor is forced from options */ | ||||
| 
 | ||||
|     CloseScreenProcPtr saved_close_screen; | ||||
|     DestroyPixmapProcPtr saved_destroy_pixmap; | ||||
|     xf86FreeScreenProc *saved_free_screen; | ||||
| }; | ||||
| 
 | ||||
|  | @ -756,31 +755,18 @@ glamor_egl_get_driver_name(ScreenPtr screen) | |||
|     return NULL; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| static Bool | ||||
| glamor_egl_destroy_pixmap(PixmapPtr pixmap) | ||||
| static void glamor_egl_pixmap_destroy(ScreenPtr pScreen, PixmapPtr pixmap, void *arg) | ||||
| { | ||||
|     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); | ||||
|     struct glamor_pixmap_private *pixmap_priv = | ||||
|         glamor_get_pixmap_private(pixmap); | ||||
| 
 | ||||
|         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; | ||||
|     if (pixmap_priv->image) | ||||
|         eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image); | ||||
| } | ||||
| 
 | ||||
| void | ||||
|  | @ -822,6 +808,7 @@ glamor_egl_close_screen(ScreenPtr screen) | |||
|     eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image); | ||||
|     pixmap_priv->image = NULL; | ||||
| 
 | ||||
|     dixScreenUnhookPixmapDestroy(screen, glamor_egl_pixmap_destroy, NULL); | ||||
|     screen->CloseScreen = glamor_egl->saved_close_screen; | ||||
| 
 | ||||
|     return screen->CloseScreen(screen); | ||||
|  | @ -907,8 +894,7 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx) | |||
|     glamor_egl->saved_close_screen = screen->CloseScreen; | ||||
|     screen->CloseScreen = glamor_egl_close_screen; | ||||
| 
 | ||||
|     glamor_egl->saved_destroy_pixmap = screen->DestroyPixmap; | ||||
|     screen->DestroyPixmap = glamor_egl_destroy_pixmap; | ||||
|     dixScreenHookPixmapDestroy(screen, glamor_egl_pixmap_destroy, NULL); | ||||
| 
 | ||||
|     glamor_ctx->ctx = glamor_egl->context; | ||||
|     glamor_ctx->display = glamor_egl->display; | ||||
|  |  | |||
|  | @ -209,7 +209,6 @@ struct glamor_saved_procs { | |||
|     CloseScreenProcPtr close_screen; | ||||
|     CreateGCProcPtr create_gc; | ||||
|     CreatePixmapProcPtr create_pixmap; | ||||
|     DestroyPixmapProcPtr destroy_pixmap; | ||||
|     GetSpansProcPtr get_spans; | ||||
|     GetImageProcPtr get_image; | ||||
|     CompositeProcPtr composite; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue