xserver/hw/xgl xgl.h, 1.10, 1.11 xglglx.c, NONE, 1.1 xglglyph.c, 1.3, 1.4 xgloffscreen.c, 1.3, 1.4 xglpict.c, 1.4, 1.5 xglpixmap.c, 1.9, 1.10 xglscreen.c, 1.6, 1.7 xglsync.c, 1.6, 1.7 xgltrap.c, 1.4, 1.5

David Reveman <xserver-commit-u7BhqnqprCWvj1b/[email protected]> Wed, 13 Apr 2005 07:27:49 -0700 (PDT)
Newsgroups gmane.comp.freedesktop.xserver.cvs
Message-ID <[email protected]>
Committed by: davidr

Update of /cvs/xserver/xserver/hw/xgl
In directory gabe:/tmp/cvs-serv10592

Modified Files:
	xgl.h xglglyph.c xgloffscreen.c xglpict.c xglpixmap.c 
	xglscreen.c xglsync.c xgltrap.c 
Added Files:
	xglglx.c 
Log Message:
Add GLX code to Xgl

Index: xgl.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/xgl/xgl.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- xgl.h	11 Mar 2005 00:58:49 -0000	1.10
+++ xgl.h	13 Apr 2005 14:27:47 -0000	1.11
@@ -351,6 +351,7 @@
     Bool	      allBits;
     unsigned long     pictureMask;
     xglGeometryPtr    pGeometry;
+    int		      lock;
 } xglPixmapRec, *xglPixmapPtr;
 
 extern int xglPixmapPrivateIndex;
@@ -1313,6 +1314,9 @@
 Bool
 xglPictureInit (ScreenPtr pScreen);
 
+void
+xglPictureClipExtents (PicturePtr pPicture,
+		       BoxPtr     extents);
 
 /* xglglyph.c */
 
@@ -1365,4 +1369,11 @@
 
 #endif
 
+#ifdef GLXEXT
+
+Bool
+xglInitVisualConfigs (ScreenPtr pScreen);
+
+#endif
+
 #endif /* _XGL_H_ */

--- NEW FILE: xglglx.c ---
(This appears to be a binary file; contents omitted.)

Index: xglglyph.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/xgl/xglglyph.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- xglglyph.c	8 Mar 2005 08:30:47 -0000	1.3
+++ xglglyph.c	13 Apr 2005 14:27:47 -0000	1.4
@@ -837,7 +837,8 @@
 }
 
 static Bool
-xglGlyphExtents (int	      nlist,
+xglGlyphExtents (PicturePtr   pDst,
+		 int	      nlist,
 		 GlyphListPtr list,
 		 GlyphPtr     *glyphs,
 		 BoxPtr	      extents)
@@ -941,6 +942,8 @@
 	}
     }
 
+    xglPictureClipExtents (pDst, extents);
+
     return overlap;
 }
 
@@ -981,20 +984,26 @@
     BoxRec	  extents;
     xglGlyphOpRec glyphOp;
     int		  xDst = list->xOff, yDst = list->yOff;
+    int		  overlap;
+    int		  target;
+
+    XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
+
+    overlap = xglGlyphExtents (pDst, nlist, list, glyphs, &extents);
+    if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
+	return;
+    
+    target = xglPrepareTarget (pDst->pDrawable);
 
     if (op != PictOpAdd && maskFormat &&
-	(xglGlyphExtents (nlist, list, glyphs, &extents) || op != PictOpOver ||
+	(overlap || op != PictOpOver ||
 	 xglGlyphListFormatId (list, nlist) != maskFormat->id))
     {
-	PixmapPtr    pPixmap;
-	xglPixmapPtr pPixmapPriv;
-	CARD32	     componentAlpha;
-	GCPtr	     pGC;
-	xRectangle   rect;
-	int	     error;
-	
-	if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
-	    return;
+	PixmapPtr  pPixmap;
+	CARD32	   componentAlpha;
+	GCPtr	   pGC;
+	xRectangle rect;
+	int	   error;
 
 	rect.x = 0;
 	rect.y = 0;
@@ -1012,7 +1021,17 @@
 			       maskFormat, CPComponentAlpha, &componentAlpha,
 			       serverClient, &error);
 	if (!pMask)
+	{
+	    (*pScreen->DestroyPixmap) (pPixmap);
 	    return;
+	}
+
+	/* make sure destination drawable is locked */
+	pPixmapPriv->lock++;
+
+	/* lock mask if we are not doing accelerated drawing to destination */
+	if (!target)
+	    XGL_GET_PIXMAP_PRIV (pPixmap)->lock = 1;
 
 	ValidatePicture (pMask);
 	pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
@@ -1020,14 +1039,9 @@
 	(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &rect);
 	FreeScratchGC (pGC);
 
-	/* all will be damaged */
-	pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
-	pPixmapPriv->damageBox.x1 = 0;
-	pPixmapPriv->damageBox.y1 = 0;
-	pPixmapPriv->damageBox.x2 = pMask->pDrawable->width;
-	pPixmapPriv->damageBox.y2 = pMask->pDrawable->height;
-
 	(*pScreen->DestroyPixmap) (pPixmap);
+
+	target = xglPrepareTarget (pMask->pDrawable);
 	
 	glyphOp.xOff = -extents.x1;
 	glyphOp.yOff = -extents.y1;
@@ -1036,6 +1050,9 @@
     }
     else
     {
+	/* make sure destination drawable is locked */
+	pPixmapPriv->lock++;
+
 	glyphOp.xOff = 0;
 	glyphOp.yOff = 0;
 	pSrcPicture = pSrc;
@@ -1043,11 +1060,7 @@
     }
 
     glyphOp.ppGlyphs = glyphs;
-    
-    if (xglPrepareTarget (pDstPicture->pDrawable))
-	glyphOp.noCache = FALSE;
-    else
-	glyphOp.noCache = TRUE;
+    glyphOp.noCache  = !target;
 
     while (nlist--)
     {
@@ -1097,6 +1110,10 @@
 	
 	FreePicture ((pointer) pMask, (XID) 0);
     }
+
+    /* release destination drawable lock */
+    pPixmapPriv->lock--;
+
 }
 
 #endif

Index: xgloffscreen.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/xgl/xgloffscreen.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- xgloffscreen.c	26 Jan 2005 10:58:52 -0000	1.3
+++ xgloffscreen.c	13 Apr 2005 14:27:47 -0000	1.4
@@ -90,6 +90,9 @@
     
     if (s1 > s2)
 	XGL_DECREMENT_PIXMAP_SCORE (pPixmapPriv, 10);
+
+    if (pPixmapPriv->lock)
+	return 1;
     
     return s1 - s2;
 }

Index: xglpict.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/xgl/xglpict.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- xglpict.c	1 Mar 2005 16:34:31 -0000	1.4
+++ xglpict.c	13 Apr 2005 14:27:47 -0000	1.5
@@ -464,4 +464,41 @@
     return TRUE;
 }
 
+void
+xglPictureClipExtents (PicturePtr pPicture,
+		       BoxPtr     extents)
+{
+    if (pPicture->clientClipType != CT_NONE)
+    {
+	BoxPtr clip = REGION_EXTENTS (pPicture->pDrawable->pScreen,
+				      (RegionPtr) pPicture->clientClip);
+
+	if (extents->x1 < pPicture->clipOrigin.x + clip->x1)
+	    extents->x1 = pPicture->clipOrigin.x + clip->x1;
+
+	if (extents->y1 < pPicture->clipOrigin.y + clip->y1)
+	    extents->y1 = pPicture->clipOrigin.y + clip->y1;
+
+	if (extents->x2 > pPicture->clipOrigin.x + clip->x2)
+	    extents->x2 = pPicture->clipOrigin.x + clip->x2;
+
+	if (extents->y2 > pPicture->clipOrigin.y + clip->y2)
+	    extents->y2 = pPicture->clipOrigin.y + clip->y2;
+    }
+    else
+    {
+	if (extents->x1 < 0)
+	    extents->x1 = 0;
+
+	if (extents->y1 < 0)
+	    extents->y1 = 0;
+
+	if (extents->x2 > pPicture->pDrawable->width)
+	    extents->x2 = pPicture->pDrawable->width;
+
+	if (extents->y2 > pPicture->pDrawable->height)
+	    extents->y2 = pPicture->pDrawable->height;
+    }
+}
+
 #endif

Index: xglpixmap.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/xgl/xglpixmap.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- xglpixmap.c	11 Mar 2005 00:58:49 -0000	1.9
+++ xglpixmap.c	13 Apr 2005 14:27:47 -0000	1.10
@@ -106,6 +106,7 @@
     pPixmapPriv->acceleratedTile = FALSE;
     pPixmapPriv->pictureMask = ~0;
     pPixmapPriv->target = xglPixmapTargetNo;
+    pPixmapPriv->lock = 0;
 
     if (pPixmapPriv->format)
     {
@@ -209,7 +210,7 @@
 xglFiniPixmap (PixmapPtr pPixmap)
 {
     XGL_PIXMAP_PRIV (pPixmap);
-        
+    
     if (pPixmapPriv->pArea)
 	xglWithdrawArea (pPixmapPriv->pArea);
 	

Index: xglscreen.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/xgl/xglscreen.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- xglscreen.c	11 Mar 2005 00:58:49 -0000	1.6
+++ xglscreen.c	13 Apr 2005 14:27:47 -0000	1.7
@@ -35,6 +35,9 @@
 #ifdef RENDER
 #include "glyphstr.h"
 #endif
+#ifdef COMPOSITE
+#include "compint.h"
+#endif
 
 int xglScreenGeneration = -1;
 int xglScreenPrivateIndex;
@@ -135,7 +138,7 @@
 	       xglScreenInfoPtr pScreenInfo)
 {
     xglScreenPtr pScreenPriv;
-    int		 depth;
+    int		 depth, bpp;
     
 #ifdef RENDER
     PictureScreenPtr pPictureScreen;
@@ -154,6 +157,7 @@
 	glitz_drawable_get_features (pScreenInfo->drawable);
 
     depth = pScreenPriv->pVisual->pPixel->depth;
+    bpp   = pScreenPriv->pVisual->pPixel->masks.bpp;
 
     if (!xglInitOffscreen (pScreen, pScreenInfo))
 	return FALSE;
@@ -190,8 +194,7 @@
     if (!fbSetupScreen (pScreen, NULL,
 			pScreenInfo->width, pScreenInfo->height,
 			monitorResolution, monitorResolution,
-			pScreenInfo->width,
-			pScreenPriv->pVisual->pPixel->masks.bpp))
+			pScreenInfo->width, bpp))
 	return FALSE;
 
     pScreen->SaveScreen = xglSaveScreen;
@@ -202,8 +205,7 @@
     if (!fbFinishScreenInit (pScreen, NULL,
 			     pScreenInfo->width, pScreenInfo->height,
 			     monitorResolution, monitorResolution,
-			     pScreenInfo->width,
-			     pScreenPriv->pVisual->pPixel->masks.bpp))
+			     pScreenInfo->width, bpp))
 	return FALSE;
 
 #ifdef MITSHM
@@ -267,6 +269,19 @@
     XGL_SCREEN_WRAP (BackingStoreFuncs.SaveAreas, xglSaveAreas);
     XGL_SCREEN_WRAP (BackingStoreFuncs.RestoreAreas, xglRestoreAreas);
 
+    if (!fbCreateDefColormap (pScreen))
+	return FALSE;
+
+#ifdef COMPOSITE
+    if (!compScreenInit (pScreen))
+	return FALSE;
+#endif
+
+#ifdef GLXEXT
+    if (!xglInitVisualConfigs (pScreen))
+	return FALSE;
+#endif
+    
     /* Damage is required */
     DamageSetup (pScreen);
 
@@ -288,13 +303,6 @@
 
     XGL_SCREEN_PRIV (pScreen);
 	
-    /* Do we want to use BackingStore?
-       miInitializeBackingStore (pScreen);
-    */
-
-    if (!fbCreateDefColormap (pScreen))
-	return FALSE;
-
     pScreenPriv->solid =
 	glitz_surface_create (pScreenPriv->drawable,
 			      pScreenPriv->pixmapFormats[32].format,

Index: xglsync.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/xgl/xglsync.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- xglsync.c	16 Mar 2005 20:05:19 -0000	1.6
+++ xglsync.c	13 Apr 2005 14:27:47 -0000	1.7
@@ -304,6 +304,9 @@
 	break;
     case xglPixmapTargetOut:
 	XGL_INCREMENT_PIXMAP_SCORE (pPixmapPriv, 10);
+
+	if (pPixmapPriv->lock)
+	    return FALSE;
 	
 	if (xglFindOffscreenArea (pDrawable->pScreen, pPixmap))
 	    return TRUE;

Index: xgltrap.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/xgl/xgltrap.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- xgltrap.c	16 Mar 2005 20:05:19 -0000	1.4
+++ xgltrap.c	13 Apr 2005 14:27:47 -0000	1.5
@@ -40,64 +40,6 @@
 /* just a guess */
 #define SMOOTH_TRAPS_ESTIMATE_RECTS(nTrap) (30 * nTrap)
 
-static PicturePtr
-xglCreateMaskPicture (ScreenPtr     pScreen, 
-		      PicturePtr    pDst,
-		      PictFormatPtr pPictFormat,
-		      CARD16	    width,
-		      CARD16	    height,
-		      Bool	    accelerate)
-{
-    PixmapPtr	 pPixmap;
-    PicturePtr	 pPicture;
-    GCPtr	 pGC;
-    int		 error;
-    xRectangle	 rect;
-
-    if (width > 32767 || height > 32767)
-	return 0;
-
-    pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 
-					pPictFormat->depth);
-    if (!pPixmap)
-	return 0;
-
-    if (!accelerate)
-    {
-	XGL_PIXMAP_PRIV (pPixmap);
-	
-	if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT))
-	{
-	    (*pScreen->DestroyPixmap) (pPixmap);
-	    return 0;
-	}
-
-	pPixmapPriv->target = xglPixmapTargetNo;
-    }
-    
-    pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
-    if (!pGC)
-    {
-	(*pScreen->DestroyPixmap) (pPixmap);
-	return 0;
-    }
-
-    rect.x = 0;
-    rect.y = 0;
-    rect.width = width;
-    rect.height = height;
-    
-    ValidateGC (&pPixmap->drawable, pGC);
-    (*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &rect);
-    FreeScratchGC (pGC);
-
-    pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat,
-			      0, 0, serverClient, &error);
-    (*pScreen->DestroyPixmap) (pPixmap);
-    
-    return pPicture;
-}
-
 #define LINE_FIXED_X(l, _y, v)			 \
     dx = (l)->p2.x - (l)->p1.x;			 \
     ex = (xFixed_32_32) ((_y) - (l)->p1.y) * dx; \
@@ -111,9 +53,10 @@
     (v) = (l)->p1.x + (xFixed) ((ex + (dy - 1)) / dy)
 
 static Bool
-xglTrapezoidBounds (int	       ntrap,
-		    xTrapezoid *traps,
-		    BoxPtr     box)
+xglTrapezoidExtents (PicturePtr pDst,
+		     int        ntrap,
+		     xTrapezoid *traps,
+		     BoxPtr     extents)
 {
     Bool	 x_overlap, overlap = FALSE;
     xFixed	 dx, dy, top, bottom;
@@ -121,24 +64,24 @@
 
     if (!ntrap)
     {
-	box->x1 = MAXSHORT;
-	box->x2 = MINSHORT;
-	box->y1 = MAXSHORT;
-	box->y2 = MINSHORT;
+	extents->x1 = MAXSHORT;
+	extents->x2 = MINSHORT;
+	extents->y1 = MAXSHORT;
+	extents->y2 = MINSHORT;
 
 	return FALSE;
     }
 
-    box->y1 = xFixedToInt (traps->top);
-    box->y2 = xFixedToInt (xFixedCeil (traps->bottom));
+    extents->y1 = xFixedToInt (traps->top);
+    extents->y2 = xFixedToInt (xFixedCeil (traps->bottom));
     
     LINE_FIXED_X (&traps->left, traps->top, top);
     LINE_FIXED_X (&traps->left, traps->bottom, bottom);
-    box->x1 = xFixedToInt (MIN (top, bottom));
+    extents->x1 = xFixedToInt (MIN (top, bottom));
     
     LINE_FIXED_X_CEIL (&traps->right, traps->top, top);
     LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom);
-    box->x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
+    extents->x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
     
     ntrap--;
     traps++;
@@ -162,35 +105,37 @@
 	x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
 	
 	x_overlap = FALSE;
-	if (x1 >= box->x2)
-	    box->x2 = x2;
-	else if (x2 <= box->x1)
-	    box->x1 = x1;
+	if (x1 >= extents->x2)
+	    extents->x2 = x2;
+	else if (x2 <= extents->x1)
+	    extents->x1 = x1;
 	else
 	{
 	    x_overlap = TRUE;
-	    if (x1 < box->x1)
-		box->x1 = x1;
-	    if (x2 > box->x2)
-		box->x2 = x2;
+	    if (x1 < extents->x1)
+		extents->x1 = x1;
+	    if (x2 > extents->x2)
+		extents->x2 = x2;
 	}
 	
-	if (y1 >= box->y2)
-	    box->y2 = y2;
-	else if (y2 <= box->y1)
-	    box->y1 = y1;	    
+	if (y1 >= extents->y2)
+	    extents->y2 = y2;
+	else if (y2 <= extents->y1)
+	    extents->y1 = y1;	    
 	else
 	{
-	    if (y1 < box->y1)
-		box->y1 = y1;
-	    if (y2 > box->y2)
-		box->y2 = y2;
+	    if (y1 < extents->y1)
+		extents->y1 = y1;
+	    if (y2 > extents->y2)
+		extents->y2 = y2;
 	    
 	    if (x_overlap)
 		overlap = TRUE;
 	}
     }
 
+    xglPictureClipExtents (pDst, extents);
+
     return overlap;
 }
 
@@ -211,24 +156,30 @@
     unsigned int    polyEdge = pDst->polyEdge;
     INT16	    xDst, yDst;
     INT16	    xOff, yOff;
-    BoxRec	    bounds;
+    BoxRec	    extents;
     Bool	    overlap;
+    Bool	    target;
     
     XGL_SCREEN_PRIV (pScreen);
+    XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
 
     xDst = traps[0].left.p1.x >> 16;
     yDst = traps[0].left.p1.y >> 16;
     
-    overlap = xglTrapezoidBounds (nTrap, traps, &bounds);
-    if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
+    overlap = xglTrapezoidExtents (pDst, nTrap, traps, &extents);
+    if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
 	return;
 
+    target = xglPrepareTarget (pDst->pDrawable);
+
     if (nTrap > 1 && op != PictOpAdd && maskFormat &&
 	(overlap || op != PictOpOver))
     {
-	xglPixmapPtr pPixmapPriv;
-	int	     width, height;
-	Bool	     accelerate;
+	PixmapPtr  pPixmap;
+	GCPtr	   pGC;
+	xRectangle rect;
+	int	   error;
+	int	   area;
 	
 	if (!pScreenPriv->pSolidAlpha)
 	{
@@ -237,39 +188,53 @@
 		return;
 	}
 
-	accelerate = TRUE;
-	width  = bounds.x2 - bounds.x1;
-	height = bounds.y2 - bounds.y1;
-	if (maskFormat->depth > 1)
-	{
-	    /* Avoid acceleration if the estimated amount of vertex data
-	       is likely to exceed the size of the mask. */
-	    if ((SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > (width * height))
-		accelerate = FALSE;
-	} else
-	    accelerate = FALSE;
+	rect.x = 0;
+	rect.y = 0;
+	rect.width = extents.x2 - extents.x1;
+	rect.height = extents.y2 - extents.y1;
 
-	pMask = xglCreateMaskPicture (pScreen, pDst, maskFormat,
-				      width, height, accelerate);
+	pPixmap = (*pScreen->CreatePixmap) (pScreen,
+					    rect.width, rect.height, 
+					    maskFormat->depth);
+	if (!pPixmap)
+	    return;
+    
+	pMask = CreatePicture (0, &pPixmap->drawable, maskFormat,
+			       0, 0, serverClient, &error);
 	if (!pMask)
+	{
+	    (*pScreen->DestroyPixmap) (pPixmap);
 	    return;
+	}
+	
+	/* make sure destination drawable is locked */
+	pPixmapPriv->lock++;
 
+	/* lock mask if we are not doing accelerated drawing to destination */
+	area = rect.width * rect.height;
+	if (!target || (SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > area)
+	    XGL_GET_PIXMAP_PRIV (pPixmap)->lock = 1;
+	
 	ValidatePicture (pMask);
+	pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+	ValidateGC (&pPixmap->drawable, pGC);
+	(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &rect);
+	FreeScratchGC (pGC);
 
-	/* all will be damaged */
-	pPixmapPriv = XGL_GET_DRAWABLE_PIXMAP_PRIV (pMask->pDrawable);
-	pPixmapPriv->damageBox.x1 = 0;
-	pPixmapPriv->damageBox.y1 = 0;
-	pPixmapPriv->damageBox.x2 = pMask->pDrawable->width;
-	pPixmapPriv->damageBox.y2 = pMask->pDrawable->height;
+	(*pScreen->DestroyPixmap) (pPixmap);
 
-	xOff = -bounds.x1;
-	yOff = -bounds.y1;
+	target = xglPrepareTarget (pMask->pDrawable);
+	
+	xOff = -extents.x1;
+	yOff = -extents.y1;
 	pSrcPicture = pScreenPriv->pSolidAlpha;
 	pDstPicture = pMask;
     }
     else
     {
+	/* make sure destination drawable is locked */
+	pPixmapPriv->lock++;
+
 	if (maskFormat)
 	{
 	    if (maskFormat->depth == 1)
@@ -284,7 +249,7 @@
 	pDstPicture = pDst;
     }
 
-    if (xglPrepareTarget (pDstPicture->pDrawable))
+    if (target)
     {
 	if (maskFormat || polyEdge == PolyEdgeSmooth)
 	{
@@ -309,7 +274,8 @@
 		{
 		    if (pMask)
 			FreePicture (pMask, 0);
-		    
+
+		    pPixmapPriv->lock--;
 		    return;
 		}
 		
@@ -337,7 +303,8 @@
 	    {
 		if (pMask)
 		    FreePicture (pMask, 0);
-		
+
+		pPixmapPriv->lock--;
 		return;
 	    }
 	    
@@ -354,13 +321,13 @@
 		 pSrcPicture,
 		 NULL,
 		 pDstPicture,
-		 bounds.x1 + xOff + xSrc - xDst,
-		 bounds.y1 + yOff + ySrc - yDst,
+		 extents.x1 + xOff + xSrc - xDst,
+		 extents.y1 + yOff + ySrc - yDst,
 		 0, 0,
-		 pDstPicture->pDrawable->x + bounds.x1 + xOff,
-		 pDstPicture->pDrawable->y + bounds.y1 + yOff,
-		 bounds.x2 - bounds.x1,
-		 bounds.y2 - bounds.y1,
+		 pDstPicture->pDrawable->x + extents.x1 + xOff,
+		 pDstPicture->pDrawable->y + extents.y1 + yOff,
+		 extents.x2 - extents.x1,
+		 extents.y2 - extents.y1,
 		 pGeometry,
 		 mask))
     {
@@ -370,7 +337,7 @@
 	{
 	    RegionRec region;
 
-	    REGION_INIT (pScreen, &region, &bounds, 1);
+	    REGION_INIT (pScreen, &region, &extents, 1);
 	    REGION_TRANSLATE (pScreen, &region,
 			      pDst->pDrawable->x, pDst->pDrawable->y);
 	    
@@ -385,10 +352,10 @@
     {
 	XGL_DRAWABLE_PIXMAP_PRIV (pDstPicture->pDrawable);
 
-	pPixmapPriv->damageBox.x1 = bounds.x1 + xOff;
-	pPixmapPriv->damageBox.y1 = bounds.y1 + yOff;
-	pPixmapPriv->damageBox.x2 = bounds.x2 + xOff;
-	pPixmapPriv->damageBox.y2 = bounds.y2 + yOff;
+	pPixmapPriv->damageBox.x1 = extents.x1 + xOff;
+	pPixmapPriv->damageBox.y1 = extents.y1 + yOff;
+	pPixmapPriv->damageBox.x2 = extents.x2 + xOff;
+	pPixmapPriv->damageBox.y2 = extents.y2 + yOff;
 
 	xglSyncDamageBoxBits (pDstPicture->pDrawable);
 
@@ -411,15 +378,18 @@
 	xglLeaveOffscreenArea ((PixmapPtr) pMask->pDrawable);
 	
 	CompositePicture (op, pSrc, pMask, pDst,
-			  bounds.x1 + xSrc - xDst,
-			  bounds.y1 + ySrc - yDst,
+			  extents.x1 + xSrc - xDst,
+			  extents.y1 + ySrc - yDst,
 			  0, 0,
-			  bounds.x1, bounds.y1,
-			  bounds.x2 - bounds.x1,
-			  bounds.y2 - bounds.y1);
+			  extents.x1, extents.y1,
+			  extents.x2 - extents.x1,
+			  extents.y2 - extents.y1);
 	
 	FreePicture (pMask, 0);
     }
+
+    /* release destination drawable lock */
+    pPixmapPriv->lock--;
 }
 
 void