(!1714) exa: 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
							
								
									987f37270b
								
							
						
					
					
						commit
						c248346e78
					
				
							
								
								
									
										16
									
								
								exa/exa.c
								
								
								
								
							
							
						
						
									
										16
									
								
								exa/exa.c
								
								
								
								
							|  | @ -740,6 +740,11 @@ exaCloseScreen(ScreenPtr pScreen) | |||
|     ExaScreenPriv(pScreen); | ||||
|     PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); | ||||
| 
 | ||||
|     /* doesn't matter which one actually was registered */ | ||||
|     dixScreenUnhookPixmapDestroy(pScreen, exaPixmapDestroy_classic, 0); | ||||
|     dixScreenUnhookPixmapDestroy(pScreen, exaPixmapDestroy_driver, 0); | ||||
|     dixScreenUnhookPixmapDestroy(pScreen, exaPixmapDestroy_mixed, 0); | ||||
| 
 | ||||
|     if (ps->Glyphs == exaGlyphs) | ||||
|         exaGlyphsFini(pScreen); | ||||
| 
 | ||||
|  | @ -753,8 +758,6 @@ exaCloseScreen(ScreenPtr pScreen) | |||
|     unwrap(pExaScr, pScreen, GetSpans); | ||||
|     if (pExaScr->SavedCreatePixmap) | ||||
|         unwrap(pExaScr, pScreen, CreatePixmap); | ||||
|     if (pExaScr->SavedDestroyPixmap) | ||||
|         unwrap(pExaScr, pScreen, DestroyPixmap); | ||||
|     if (pExaScr->SavedModifyPixmapHeader) | ||||
|         unwrap(pExaScr, pScreen, ModifyPixmapHeader); | ||||
|     unwrap(pExaScr, pScreen, CopyWindow); | ||||
|  | @ -955,8 +958,9 @@ exaDriverInit(ScreenPtr pScreen, ExaDriverPtr pScreenInfo) | |||
|         } | ||||
|         if (pExaScr->info->flags & EXA_HANDLES_PIXMAPS) { | ||||
|             if (pExaScr->info->flags & EXA_MIXED_PIXMAPS) { | ||||
|                 dixScreenHookPixmapDestroy(pScreen, exaPixmapDestroy_mixed, 0); | ||||
| 
 | ||||
|                 wrap(pExaScr, pScreen, CreatePixmap, exaCreatePixmap_mixed); | ||||
|                 wrap(pExaScr, pScreen, DestroyPixmap, exaDestroyPixmap_mixed); | ||||
|                 wrap(pExaScr, pScreen, ModifyPixmapHeader, | ||||
|                      exaModifyPixmapHeader_mixed); | ||||
|                 wrap(pExaScr, pScreen, SharePixmapBacking, exaSharePixmapBacking_mixed); | ||||
|  | @ -969,8 +973,9 @@ exaDriverInit(ScreenPtr pScreen, ExaDriverPtr pScreenInfo) | |||
|                 pExaScr->prepare_access_reg = exaPrepareAccessReg_mixed; | ||||
|             } | ||||
|             else { | ||||
|                 dixScreenHookPixmapDestroy(pScreen, exaPixmapDestroy_driver, 0); | ||||
| 
 | ||||
|                 wrap(pExaScr, pScreen, CreatePixmap, exaCreatePixmap_driver); | ||||
|                 wrap(pExaScr, pScreen, DestroyPixmap, exaDestroyPixmap_driver); | ||||
|                 wrap(pExaScr, pScreen, ModifyPixmapHeader, | ||||
|                      exaModifyPixmapHeader_driver); | ||||
|                 pExaScr->do_migration = NULL; | ||||
|  | @ -981,8 +986,9 @@ exaDriverInit(ScreenPtr pScreen, ExaDriverPtr pScreenInfo) | |||
|             } | ||||
|         } | ||||
|         else { | ||||
|             dixScreenHookPixmapDestroy(pScreen, exaPixmapDestroy_classic, 0); | ||||
| 
 | ||||
|             wrap(pExaScr, pScreen, CreatePixmap, exaCreatePixmap_classic); | ||||
|             wrap(pExaScr, pScreen, DestroyPixmap, exaDestroyPixmap_classic); | ||||
|             wrap(pExaScr, pScreen, ModifyPixmapHeader, | ||||
|                  exaModifyPixmapHeader_classic); | ||||
|             pExaScr->do_migration = exaDoMigration_classic; | ||||
|  |  | |||
|  | @ -206,42 +206,26 @@ exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, | |||
|     return ret; | ||||
| } | ||||
| 
 | ||||
| Bool | ||||
| exaDestroyPixmap_classic(PixmapPtr pPixmap) | ||||
| void exaPixmapDestroy_classic(ScreenPtr pScreen, PixmapPtr pPixmap, void *arg) | ||||
| { | ||||
|     ScreenPtr pScreen = pPixmap->drawable.pScreen; | ||||
|     ExaPixmapPriv(pPixmap); | ||||
|     if (!pExaPixmap) // we're called on an error path
 | ||||
|         return; | ||||
| 
 | ||||
|     ExaScreenPriv(pScreen); | ||||
|     Bool ret = TRUE; | ||||
|     exaDestroyPixmap(pPixmap); | ||||
| 
 | ||||
|     if (pPixmap->refcnt == 1) { | ||||
|         ExaPixmapPriv(pPixmap); | ||||
|         if (!pExaPixmap) // we're called on an error path
 | ||||
|             goto out; | ||||
| 
 | ||||
|         exaDestroyPixmap(pPixmap); | ||||
| 
 | ||||
|         if (pExaPixmap->area) { | ||||
|             DBG_PIXMAP(("-- 0x%p (0x%x) (%dx%d)\n", | ||||
|                         (void *) pPixmap->drawable.id, | ||||
|                         ExaGetPixmapPriv(pPixmap)->area->offset, | ||||
|                         pPixmap->drawable.width, pPixmap->drawable.height)); | ||||
|             /* Free the offscreen area */ | ||||
|             exaOffscreenFree(pPixmap->drawable.pScreen, pExaPixmap->area); | ||||
|             pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr; | ||||
|             pPixmap->devKind = pExaPixmap->sys_pitch; | ||||
|         } | ||||
|         RegionUninit(&pExaPixmap->validSys); | ||||
|         RegionUninit(&pExaPixmap->validFB); | ||||
|     if (pExaPixmap->area) { | ||||
|         DBG_PIXMAP(("-- 0x%p (0x%x) (%dx%d)\n", | ||||
|                     (void *) pPixmap->drawable.id, | ||||
|                     ExaGetPixmapPriv(pPixmap)->area->offset, | ||||
|                     pPixmap->drawable.width, pPixmap->drawable.height)); | ||||
|         /* Free the offscreen area */ | ||||
|         exaOffscreenFree(pPixmap->drawable.pScreen, pExaPixmap->area); | ||||
|         pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr; | ||||
|         pPixmap->devKind = pExaPixmap->sys_pitch; | ||||
|     } | ||||
| 
 | ||||
| out: | ||||
|     // restore original (screen driver's) DestroyPixmap() handler and call it
 | ||||
|     swap(pExaScr, pScreen, DestroyPixmap); | ||||
|     dixDestroyPixmap(pPixmap, 0); | ||||
|     swap(pExaScr, pScreen, DestroyPixmap); | ||||
| 
 | ||||
|     return ret; | ||||
|     RegionUninit(&pExaPixmap->validSys); | ||||
|     RegionUninit(&pExaPixmap->validFB); | ||||
| } | ||||
| 
 | ||||
| Bool | ||||
|  |  | |||
|  | @ -185,33 +185,19 @@ exaModifyPixmapHeader_driver(PixmapPtr pPixmap, int width, int height, | |||
|     return ret; | ||||
| } | ||||
| 
 | ||||
| Bool | ||||
| exaDestroyPixmap_driver(PixmapPtr pPixmap) | ||||
| void exaPixmapDestroy_driver(ScreenPtr pScreen, PixmapPtr pPixmap, void *arg) | ||||
| { | ||||
|     ScreenPtr pScreen = pPixmap->drawable.pScreen; | ||||
| 
 | ||||
|     ExaScreenPriv(pScreen); | ||||
|     Bool ret = TRUE; | ||||
| 
 | ||||
|     if (pPixmap->refcnt == 1) { | ||||
|         ExaPixmapPriv(pPixmap); | ||||
|         if (!pExaPixmap) // we're called on an error path
 | ||||
|             goto out; | ||||
|     ExaPixmapPriv(pPixmap); | ||||
|     if (!pExaPixmap) // we're called on an error path
 | ||||
|         return; | ||||
| 
 | ||||
|         exaDestroyPixmap(pPixmap); | ||||
|     exaDestroyPixmap(pPixmap); | ||||
| 
 | ||||
|         if (pExaPixmap->driverPriv) | ||||
|             pExaScr->info->DestroyPixmap(pScreen, pExaPixmap->driverPriv); | ||||
|         pExaPixmap->driverPriv = NULL; | ||||
|     } | ||||
| 
 | ||||
| out: | ||||
|     // restore original (screen driver's) DestroyPixmap() handler and call it
 | ||||
|     swap(pExaScr, pScreen, DestroyPixmap); | ||||
|     dixDestroyPixmap(pPixmap, 0); | ||||
|     swap(pExaScr, pScreen, DestroyPixmap); | ||||
| 
 | ||||
|     return ret; | ||||
|     if (pExaPixmap->driverPriv) | ||||
|         pExaScr->info->DestroyPixmap(pScreen, pExaPixmap->driverPriv); | ||||
|     pExaPixmap->driverPriv = NULL; | ||||
| } | ||||
| 
 | ||||
| Bool | ||||
|  |  | |||
|  | @ -239,42 +239,28 @@ exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth, | |||
|     return ret; | ||||
| } | ||||
| 
 | ||||
| Bool | ||||
| exaDestroyPixmap_mixed(PixmapPtr pPixmap) | ||||
| void exaPixmapDestroy_mixed(ScreenPtr pScreen, PixmapPtr pPixmap, void *arg) | ||||
| { | ||||
|     ScreenPtr pScreen = pPixmap->drawable.pScreen; | ||||
| 
 | ||||
|     ExaScreenPriv(pScreen); | ||||
|     Bool ret = TRUE; | ||||
| 
 | ||||
|     if (pPixmap->refcnt == 1) { | ||||
|         ExaPixmapPriv(pPixmap); | ||||
|         if (!pExaPixmap) | ||||
|             goto out; // we're called on an error path
 | ||||
|     ExaPixmapPriv(pPixmap); | ||||
|     if (!pExaPixmap) // we're called on an error path
 | ||||
|         return; | ||||
| 
 | ||||
|         exaDestroyPixmap(pPixmap); | ||||
|     exaDestroyPixmap(pPixmap); | ||||
| 
 | ||||
|         if (pExaScr->deferred_mixed_pixmap == pPixmap) | ||||
|             pExaScr->deferred_mixed_pixmap = NULL; | ||||
|     if (pExaScr->deferred_mixed_pixmap == pPixmap) | ||||
|         pExaScr->deferred_mixed_pixmap = NULL; | ||||
| 
 | ||||
|         if (pExaPixmap->driverPriv) | ||||
|             pExaScr->info->DestroyPixmap(pScreen, pExaPixmap->driverPriv); | ||||
|         pExaPixmap->driverPriv = NULL; | ||||
|     if (pExaPixmap->driverPriv) | ||||
|         pExaScr->info->DestroyPixmap(pScreen, pExaPixmap->driverPriv); | ||||
|     pExaPixmap->driverPriv = NULL; | ||||
| 
 | ||||
|         if (pExaPixmap->pDamage) { | ||||
|             free(pExaPixmap->sys_ptr); | ||||
|             pExaPixmap->sys_ptr = NULL; | ||||
|             pExaPixmap->pDamage = NULL; | ||||
|         } | ||||
|     if (pExaPixmap->pDamage) { | ||||
|         free(pExaPixmap->sys_ptr); | ||||
|         pExaPixmap->sys_ptr = NULL; | ||||
|         pExaPixmap->pDamage = NULL; | ||||
|     } | ||||
| 
 | ||||
| out: | ||||
|     // restore original (screen driver's) DestroyPixmap() handler and call it
 | ||||
|     swap(pExaScr, pScreen, DestroyPixmap); | ||||
|     dixDestroyPixmap(pPixmap, 0); | ||||
|     swap(pExaScr, pScreen, DestroyPixmap); | ||||
| 
 | ||||
|     return ret; | ||||
| } | ||||
| 
 | ||||
| Bool | ||||
|  |  | |||
|  | @ -156,7 +156,6 @@ typedef struct { | |||
|     GetImageProcPtr SavedGetImage; | ||||
|     GetSpansProcPtr SavedGetSpans; | ||||
|     CreatePixmapProcPtr SavedCreatePixmap; | ||||
|     DestroyPixmapProcPtr SavedDestroyPixmap; | ||||
|     CopyWindowProcPtr SavedCopyWindow; | ||||
|     ChangeWindowAttributesProcPtr SavedChangeWindowAttributes; | ||||
|     BitmapToRegionProcPtr SavedBitmapToRegion; | ||||
|  | @ -590,8 +589,7 @@ exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, | |||
|                               int depth, int bitsPerPixel, int devKind, | ||||
|                               void *pPixData); | ||||
| 
 | ||||
| Bool | ||||
|  exaDestroyPixmap_classic(PixmapPtr pPixmap); | ||||
| void  exaPixmapDestroy_classic(ScreenPtr pScreen, PixmapPtr pPixmap, void *arg); | ||||
| 
 | ||||
| Bool | ||||
|  exaPixmapHasGpuCopy_classic(PixmapPtr pPixmap); | ||||
|  | @ -608,8 +606,7 @@ exaModifyPixmapHeader_driver(PixmapPtr pPixmap, int width, int height, | |||
|                              int depth, int bitsPerPixel, int devKind, | ||||
|                              void *pPixData); | ||||
| 
 | ||||
| Bool | ||||
|  exaDestroyPixmap_driver(PixmapPtr pPixmap); | ||||
| void exaPixmapDestroy_driver(ScreenPtr pScreen, PixmapPtr pPixmap, void *arg); | ||||
| 
 | ||||
| Bool | ||||
|  exaPixmapHasGpuCopy_driver(PixmapPtr pPixmap); | ||||
|  | @ -625,8 +622,7 @@ Bool | |||
| exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth, | ||||
|                             int bitsPerPixel, int devKind, void *pPixData); | ||||
| 
 | ||||
| Bool | ||||
|  exaDestroyPixmap_mixed(PixmapPtr pPixmap); | ||||
| void exaPixmapDestroy_mixed(ScreenPtr pScreen, PixmapPtr pPixmap, void *arg); | ||||
| 
 | ||||
| Bool | ||||
|  exaPixmapHasGpuCopy_mixed(PixmapPtr pPixmap); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue