From 0540c46066f938ad5611c56081cfcd8457a9b718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Tue, 13 Jul 2010 14:56:53 +0200 Subject: [PATCH] EXA: Finish access to pixmap if it's prepared at destruction time. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously we assumed every pixmap destroyed during a software fallback was also created during a software fallback and had access prepared, but that's not always true. Fixes a server abort Reported-by: 邓逸昕 Signed-off-by: Michel Dänzer Acked-by: Maarten Maathuis Signed-off-by: Keith Packard --- exa/exa.c | 23 +++++++++++++++++++++++ exa/exa_classic.c | 4 +--- exa/exa_driver.c | 4 +--- exa/exa_mixed.c | 4 +--- exa/exa_priv.h | 3 +++ 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/exa/exa.c b/exa/exa.c index 118a11098..fc15c2471 100644 --- a/exa/exa.c +++ b/exa/exa.c @@ -435,6 +435,29 @@ exaFinishAccess(DrawablePtr pDrawable, int index) (*pExaScr->info->FinishAccess) (pPixmap, i); } + +/** + * Helper for things common to all schemes when a pixmap is destroyed + */ +void +exaDestroyPixmap(PixmapPtr pPixmap) +{ + ExaScreenPriv(pPixmap->drawable.pScreen); + int i; + + /* Finish access if it was prepared (e.g. pixmap created during + * software fallback) + */ + for (i = 0; i < EXA_NUM_PREPARE_INDICES; i++) { + if (pExaScr->access[i].pixmap == pPixmap) { + exaFinishAccess(&pPixmap->drawable, i); + pExaScr->access[i].pixmap = NULL; + break; + } + } +} + + /** * Here begins EXA's GC code. * Do not ever access the fb/mi layer directly. diff --git a/exa/exa_classic.c b/exa/exa_classic.c index 2cfeda5fa..169ce3aac 100644 --- a/exa/exa_classic.c +++ b/exa/exa_classic.c @@ -221,9 +221,7 @@ exaDestroyPixmap_classic (PixmapPtr pPixmap) { ExaPixmapPriv (pPixmap); - /* During a fallback we must finish access, but we don't know the index. */ - if (pExaScr->fallback_counter) - exaFinishAccess(&pPixmap->drawable, -1); + exaDestroyPixmap(pPixmap); if (pExaPixmap->area) { diff --git a/exa/exa_driver.c b/exa/exa_driver.c index abe79baad..a913cfb02 100644 --- a/exa/exa_driver.c +++ b/exa/exa_driver.c @@ -193,9 +193,7 @@ exaDestroyPixmap_driver (PixmapPtr pPixmap) { ExaPixmapPriv (pPixmap); - /* During a fallback we must finish access, but we don't know the index. */ - if (pExaScr->fallback_counter) - exaFinishAccess(&pPixmap->drawable, -1); + exaDestroyPixmap(pPixmap); if (pExaPixmap->driverPriv) pExaScr->info->DestroyPixmap(pScreen, pExaPixmap->driverPriv); diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c index 7fa771d49..ef20eb502 100644 --- a/exa/exa_mixed.c +++ b/exa/exa_mixed.c @@ -245,9 +245,7 @@ exaDestroyPixmap_mixed(PixmapPtr pPixmap) { ExaPixmapPriv (pPixmap); - /* During a fallback we must finish access, but we don't know the index. */ - if (pExaScr->fallback_counter) - exaFinishAccess(&pPixmap->drawable, -1); + exaDestroyPixmap(pPixmap); if (pExaScr->deferred_mixed_pixmap == pPixmap) pExaScr->deferred_mixed_pixmap = NULL; diff --git a/exa/exa_priv.h b/exa/exa_priv.h index 58d04b0de..e5d90d468 100644 --- a/exa/exa_priv.h +++ b/exa/exa_priv.h @@ -550,6 +550,9 @@ exaPrepareAccess(DrawablePtr pDrawable, int index); void exaFinishAccess(DrawablePtr pDrawable, int index); +void +exaDestroyPixmap(PixmapPtr pPixmap); + void exaPixmapDirty(PixmapPtr pPix, int x1, int y1, int x2, int y2);