xserver/hw/xgl xglglyph.c,1.2,1.3

David Reveman xserver-commit at pdx.freedesktop.org
Tue Mar 8 00:30:49 PST 2005


Committed by: davidr

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

Modified Files:
	xglglyph.c 
Log Message:
Fix Xgl glyph caching

Index: xglglyph.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/xgl/xglglyph.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- xglglyph.c	11 Feb 2005 20:19:20 -0000	1.2
+++ xglglyph.c	8 Mar 2005 08:30:47 -0000	1.3
@@ -135,19 +135,9 @@
 		      pointer	 closure1,
 		      pointer	 closure2)
 {
-    xglGlyphCachePtr pCache = (xglGlyphCachePtr) pArea->pRoot->closure;
-    GlyphPtr	     pGlyph = (GlyphPtr) closure2;
-    xglGlyphAreaPtr  pAreaPriv;
-
-    XGL_GLYPH_PRIV (pCache->pScreen, pGlyph);
-
-    /* this shouldn't be needed, seems like a bug in xglarea.c */
-    if (!pGlyphPriv->pArea)
-	return 1;
-
-    pAreaPriv = GLYPH_GET_AREA_PRIV (pGlyphPriv->pArea);
+    GLYPH_AREA_PRIV (pArea);
 
-    if (pAreaPriv->serial != glyphSerialNumber)
+    if (pAreaPriv->serial == glyphSerialNumber)
 	return 1;
 
     return -1;
@@ -388,6 +378,7 @@
 		
 		GLYPH_AREA_PRIV (pGlyphPriv->pArea);
 
+		pAreaPriv->serial = glyphSerialNumber;
 		pAreaPriv->u.range.first = pGlyphPriv->pArea->x * 4;
 		pAreaPriv->u.range.count = nBox * 4;
 
@@ -454,6 +445,7 @@
 		glitz_surface_translate_point (pTexture->mask, &p1, &p1);
 		glitz_surface_translate_point (pTexture->mask, &p2, &p2);
 		
+		pAreaPriv->serial = glyphSerialNumber;
 		if (pTexture->geometryDataType)
 		{
 		    pAreaPriv->u.box.fBox.x1 = FIXED_TO_FLOAT (p1.x);
@@ -499,7 +491,15 @@
     XGL_SCREEN_PRIV (pScreen);
 
     pCache = &pScreenPriv->glyphCache[depth];
-
+    if (usingCache)
+    {
+	if (!pCache->pScreen)
+	{
+	    if (!xglInitGlyphCache (pCache, pScreen, pOp->pLists->format))
+		usingCache = FALSE;
+	}
+    }
+    
     while (pOp->nGlyphs)
     {
 	glyph = *pOp->ppGlyphs;
@@ -518,22 +518,14 @@
 	if (usingCache)
 	{
 	    pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, glyph);
+	    pArea = pGlyphPriv->pArea;
 	    if (pSrc)
 	    {
-		pArea = pGlyphPriv->pArea;
+		if (!pArea)
+		    pArea = xglCacheGlyph (pCache, glyph);
+	    
 		if (pArea)
 		    break;
-
-		if (pCache->pScreen ||
-		    xglInitGlyphCache (pCache, pScreen, pOp->pLists->format))
-		{
-		    if (xglCacheGlyph (pCache, glyph))
-			break;
-		}
-	    }
-	    else
-	    {
-		pArea = pGlyphPriv->pArea;
 	    }
 	} else
 	    pArea = NULL;
@@ -556,8 +548,7 @@
 	    pPixmap = GetScratchPixmapHeader (pScreen,
 					      glyph->info.width,
 					      glyph->info.height, 
-					      pOp->pLists->format->depth,
-					      pOp->pLists->format->depth,
+					      depth, depth,
 					      0, (pointer) (glyph + 1));
 	    if (!pPixmap)
 		return;
@@ -631,7 +622,8 @@
     BoxRec		  extents;
     INT16		  xOff, yOff, x1, x2, y1, y2;
     int			  depth = pOp->pLists->format->depth;
-    int			  n, count = 0, remaining = pOp->nGlyphs;
+    int			  i, remaining = pOp->nGlyphs;
+    int			  nGlyph = 0;
     glitz_surface_t	  *mask = NULL;
 
     XGL_SCREEN_PRIV (pScreen);
@@ -640,40 +632,76 @@
     if (!pCache->pScreen)
     {
 	if (!xglInitGlyphCache (pCache, pScreen, pOp->pLists->format))
+	{
+	    pOp->noCache = TRUE;
 	    return 1;
+	}
     }
 
-    if (depth == 1)
+    /* update serial number for all glyphs already in cache so that
+       we don't accidentally replace one. */
+    for (i = 0; i < pOp->nGlyphs; i++)
     {
-	glitz_multi_array_t *multiArray;
-
-	pGeometry = &pCache->u.geometry;
-	pGeometry->xOff = pGeometry->yOff = 0;
-	
-	multiArray = glitz_multi_array_create (pOp->nGlyphs);
-	if (!multiArray)
-	    return 1;
+	pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pOp->ppGlyphs[i]);
+	pArea = pGlyphPriv->pArea;
+	if (pArea && pArea->width)
+	    GLYPH_GET_AREA_PRIV (pArea)->serial = glyphSerialNumber;
+    }
 
-	GEOMETRY_SET_MULTI_ARRAY (pGeometry, multiArray);
-	glitz_multi_array_destroy (multiArray);
+    for (i = 0; i < pOp->nGlyphs; i++)
+    {
+	pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pOp->ppGlyphs[i]);
+	pArea = pGlyphPriv->pArea;
+	if (!pArea)
+	    pArea = xglCacheGlyph (pCache, pOp->ppGlyphs[i]);
 
-	vData.array.lastX = 0;
-	vData.array.lastY = 0;
+	if (pArea)
+	{
+	    if (pArea->width)
+		nGlyph++;
+	}
+	else if (pSrc)
+	    break;
     }
-    else
+    
+    if (nGlyph)
     {
-	n = pCache->u.texture.format.vertex.bytes_per_vertex;
-	pGeometry = xglGetScratchGeometryWithSize (pScreen, 4 * n * remaining);
-	
-	pGeometry->f = pCache->u.texture.format;
-	pGeometry->type	= GLITZ_GEOMETRY_TYPE_VERTEX;
-	mask = pCache->u.texture.mask;
-	
-	vData.list.s = glitz_buffer_map (pGeometry->buffer,
-					 GLITZ_BUFFER_ACCESS_WRITE_ONLY);
-    }
+	if (depth == 1)
+	{
+	    glitz_multi_array_t *multiArray;
+	    
+	    pGeometry = &pCache->u.geometry;
+	    pGeometry->xOff = pGeometry->yOff = 0;
+	    
+	    multiArray = glitz_multi_array_create (nGlyph);
+	    if (!multiArray)
+		return 1;
+	    
+	    GEOMETRY_SET_MULTI_ARRAY (pGeometry, multiArray);
+	    glitz_multi_array_destroy (multiArray);
+	    
+	    vData.array.lastX = 0;
+	    vData.array.lastY = 0;
+	}
+	else
+	{
+	    i = 4 * pCache->u.texture.format.vertex.bytes_per_vertex * nGlyph;
+	    pGeometry = xglGetScratchGeometryWithSize (pScreen, i);
+	    
+	    pGeometry->f = pCache->u.texture.format;
+	    pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
+	    mask = pCache->u.texture.mask;
+	    
+	    vData.list.s = glitz_buffer_map (pGeometry->buffer,
+					     GLITZ_BUFFER_ACCESS_WRITE_ONLY);
+	}
+    } else
+	pGeometry = NULL;
 
-    NEXT_GLYPH_SERIAL_NUMBER;
+    extents.x1 = MAXSHORT;
+    extents.y1 = MAXSHORT;
+    extents.x2 = MINSHORT;
+    extents.y2 = MINSHORT;
 
     while (pOp->nGlyphs)
     {
@@ -692,21 +720,8 @@
 
 	pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, glyph);
 	pArea = pGlyphPriv->pArea;
-	if (!pArea)
-	{
-	    n = pOp->nGlyphs;
-	    while (n--)
-	    {
-		pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pOp->ppGlyphs[n]);
-		pArea = pGlyphPriv->pArea;
-		if (pArea && pArea->width)
-		    GLYPH_GET_AREA_PRIV (pArea)->serial = glyphSerialNumber;
-	    }
-	    
-	    pArea = xglCacheGlyph (pCache, glyph);
-	    if (!pArea && pSrc)
-		break;
-	}
+	if (!pArea && pSrc)
+	    break;
 
 	pOp->listLen--;
 	pOp->nGlyphs--;
@@ -758,19 +773,20 @@
 			       pGlyphArea->u.box.sBox);
 		}
 	    }
-	    count++;
 	}
 	remaining--;
     }
 
-    if (depth != 1)
-    {
-	glitz_buffer_unmap (pGeometry->buffer);
-	pGeometry->count = count * 4;
-    }
+    NEXT_GLYPH_SERIAL_NUMBER;
 
-    if (count)
+    if (nGlyph)
     {
+	if (depth != 1)
+	{
+	    glitz_buffer_unmap (pGeometry->buffer);
+	    pGeometry->count = nGlyph * 4;
+	}
+	
 	xSrc += extents.x1;
 	ySrc += extents.y1;
 
@@ -780,7 +796,7 @@
 	    pSrc = pScreenPriv->pSolidAlpha;
 	    
 	    if (remaining)
-		*pOp = opSave;
+	    	*pOp = opSave;
 	}
 
 	GEOMETRY_TRANSLATE (pGeometry,
@@ -805,15 +821,15 @@
 	}
 
 	remaining = ~0;
-	pOp->noCache = TRUE;
 	*pOp = opSave;
+	pOp->noCache = TRUE;
     }
     else
     {
 	if (remaining)
 	{
-	    pOp->noCache = TRUE;
 	    *pOp = opSave;
+	    pOp->noCache = TRUE;
 	}
     }
 



More information about the xserver-commit mailing list