Fix Xgl glyph caching
This commit is contained in:
parent
8d0e520721
commit
e26a096cb6
|
@ -135,19 +135,9 @@ xglGlyphCompareScore (xglAreaPtr pArea,
|
||||||
pointer closure1,
|
pointer closure1,
|
||||||
pointer closure2)
|
pointer closure2)
|
||||||
{
|
{
|
||||||
xglGlyphCachePtr pCache = (xglGlyphCachePtr) pArea->pRoot->closure;
|
GLYPH_AREA_PRIV (pArea);
|
||||||
GlyphPtr pGlyph = (GlyphPtr) closure2;
|
|
||||||
xglGlyphAreaPtr pAreaPriv;
|
|
||||||
|
|
||||||
XGL_GLYPH_PRIV (pCache->pScreen, pGlyph);
|
if (pAreaPriv->serial == glyphSerialNumber)
|
||||||
|
|
||||||
/* this shouldn't be needed, seems like a bug in xglarea.c */
|
|
||||||
if (!pGlyphPriv->pArea)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
pAreaPriv = GLYPH_GET_AREA_PRIV (pGlyphPriv->pArea);
|
|
||||||
|
|
||||||
if (pAreaPriv->serial != glyphSerialNumber)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -388,6 +378,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
|
||||||
|
|
||||||
GLYPH_AREA_PRIV (pGlyphPriv->pArea);
|
GLYPH_AREA_PRIV (pGlyphPriv->pArea);
|
||||||
|
|
||||||
|
pAreaPriv->serial = glyphSerialNumber;
|
||||||
pAreaPriv->u.range.first = pGlyphPriv->pArea->x * 4;
|
pAreaPriv->u.range.first = pGlyphPriv->pArea->x * 4;
|
||||||
pAreaPriv->u.range.count = nBox * 4;
|
pAreaPriv->u.range.count = nBox * 4;
|
||||||
|
|
||||||
|
@ -454,6 +445,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
|
||||||
glitz_surface_translate_point (pTexture->mask, &p1, &p1);
|
glitz_surface_translate_point (pTexture->mask, &p1, &p1);
|
||||||
glitz_surface_translate_point (pTexture->mask, &p2, &p2);
|
glitz_surface_translate_point (pTexture->mask, &p2, &p2);
|
||||||
|
|
||||||
|
pAreaPriv->serial = glyphSerialNumber;
|
||||||
if (pTexture->geometryDataType)
|
if (pTexture->geometryDataType)
|
||||||
{
|
{
|
||||||
pAreaPriv->u.box.fBox.x1 = FIXED_TO_FLOAT (p1.x);
|
pAreaPriv->u.box.fBox.x1 = FIXED_TO_FLOAT (p1.x);
|
||||||
|
@ -499,7 +491,15 @@ xglUncachedGlyphs (CARD8 op,
|
||||||
XGL_SCREEN_PRIV (pScreen);
|
XGL_SCREEN_PRIV (pScreen);
|
||||||
|
|
||||||
pCache = &pScreenPriv->glyphCache[depth];
|
pCache = &pScreenPriv->glyphCache[depth];
|
||||||
|
if (usingCache)
|
||||||
|
{
|
||||||
|
if (!pCache->pScreen)
|
||||||
|
{
|
||||||
|
if (!xglInitGlyphCache (pCache, pScreen, pOp->pLists->format))
|
||||||
|
usingCache = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (pOp->nGlyphs)
|
while (pOp->nGlyphs)
|
||||||
{
|
{
|
||||||
glyph = *pOp->ppGlyphs;
|
glyph = *pOp->ppGlyphs;
|
||||||
|
@ -518,22 +518,14 @@ xglUncachedGlyphs (CARD8 op,
|
||||||
if (usingCache)
|
if (usingCache)
|
||||||
{
|
{
|
||||||
pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, glyph);
|
pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, glyph);
|
||||||
|
pArea = pGlyphPriv->pArea;
|
||||||
if (pSrc)
|
if (pSrc)
|
||||||
{
|
{
|
||||||
pArea = pGlyphPriv->pArea;
|
if (!pArea)
|
||||||
|
pArea = xglCacheGlyph (pCache, glyph);
|
||||||
|
|
||||||
if (pArea)
|
if (pArea)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (pCache->pScreen ||
|
|
||||||
xglInitGlyphCache (pCache, pScreen, pOp->pLists->format))
|
|
||||||
{
|
|
||||||
if (xglCacheGlyph (pCache, glyph))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pArea = pGlyphPriv->pArea;
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
pArea = NULL;
|
pArea = NULL;
|
||||||
|
@ -556,8 +548,7 @@ xglUncachedGlyphs (CARD8 op,
|
||||||
pPixmap = GetScratchPixmapHeader (pScreen,
|
pPixmap = GetScratchPixmapHeader (pScreen,
|
||||||
glyph->info.width,
|
glyph->info.width,
|
||||||
glyph->info.height,
|
glyph->info.height,
|
||||||
pOp->pLists->format->depth,
|
depth, depth,
|
||||||
pOp->pLists->format->depth,
|
|
||||||
0, (pointer) (glyph + 1));
|
0, (pointer) (glyph + 1));
|
||||||
if (!pPixmap)
|
if (!pPixmap)
|
||||||
return;
|
return;
|
||||||
|
@ -631,7 +622,8 @@ xglCachedGlyphs (CARD8 op,
|
||||||
BoxRec extents;
|
BoxRec extents;
|
||||||
INT16 xOff, yOff, x1, x2, y1, y2;
|
INT16 xOff, yOff, x1, x2, y1, y2;
|
||||||
int depth = pOp->pLists->format->depth;
|
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;
|
glitz_surface_t *mask = NULL;
|
||||||
|
|
||||||
XGL_SCREEN_PRIV (pScreen);
|
XGL_SCREEN_PRIV (pScreen);
|
||||||
|
@ -640,40 +632,76 @@ xglCachedGlyphs (CARD8 op,
|
||||||
if (!pCache->pScreen)
|
if (!pCache->pScreen)
|
||||||
{
|
{
|
||||||
if (!xglInitGlyphCache (pCache, pScreen, pOp->pLists->format))
|
if (!xglInitGlyphCache (pCache, pScreen, pOp->pLists->format))
|
||||||
|
{
|
||||||
|
pOp->noCache = TRUE;
|
||||||
return 1;
|
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;
|
pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pOp->ppGlyphs[i]);
|
||||||
|
pArea = pGlyphPriv->pArea;
|
||||||
pGeometry = &pCache->u.geometry;
|
if (pArea && pArea->width)
|
||||||
pGeometry->xOff = pGeometry->yOff = 0;
|
GLYPH_GET_AREA_PRIV (pArea)->serial = glyphSerialNumber;
|
||||||
|
|
||||||
multiArray = glitz_multi_array_create (pOp->nGlyphs);
|
|
||||||
if (!multiArray)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
GEOMETRY_SET_MULTI_ARRAY (pGeometry, multiArray);
|
|
||||||
glitz_multi_array_destroy (multiArray);
|
|
||||||
|
|
||||||
vData.array.lastX = 0;
|
|
||||||
vData.array.lastY = 0;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
for (i = 0; i < pOp->nGlyphs; i++)
|
||||||
{
|
{
|
||||||
n = pCache->u.texture.format.vertex.bytes_per_vertex;
|
pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pOp->ppGlyphs[i]);
|
||||||
pGeometry = xglGetScratchGeometryWithSize (pScreen, 4 * n * remaining);
|
pArea = pGlyphPriv->pArea;
|
||||||
|
if (!pArea)
|
||||||
pGeometry->f = pCache->u.texture.format;
|
pArea = xglCacheGlyph (pCache, pOp->ppGlyphs[i]);
|
||||||
pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
|
|
||||||
mask = pCache->u.texture.mask;
|
|
||||||
|
|
||||||
vData.list.s = glitz_buffer_map (pGeometry->buffer,
|
|
||||||
GLITZ_BUFFER_ACCESS_WRITE_ONLY);
|
|
||||||
}
|
|
||||||
|
|
||||||
NEXT_GLYPH_SERIAL_NUMBER;
|
if (pArea)
|
||||||
|
{
|
||||||
|
if (pArea->width)
|
||||||
|
nGlyph++;
|
||||||
|
}
|
||||||
|
else if (pSrc)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nGlyph)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
extents.x1 = MAXSHORT;
|
||||||
|
extents.y1 = MAXSHORT;
|
||||||
|
extents.x2 = MINSHORT;
|
||||||
|
extents.y2 = MINSHORT;
|
||||||
|
|
||||||
while (pOp->nGlyphs)
|
while (pOp->nGlyphs)
|
||||||
{
|
{
|
||||||
|
@ -692,21 +720,8 @@ xglCachedGlyphs (CARD8 op,
|
||||||
|
|
||||||
pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, glyph);
|
pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, glyph);
|
||||||
pArea = pGlyphPriv->pArea;
|
pArea = pGlyphPriv->pArea;
|
||||||
if (!pArea)
|
if (!pArea && pSrc)
|
||||||
{
|
break;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
pOp->listLen--;
|
pOp->listLen--;
|
||||||
pOp->nGlyphs--;
|
pOp->nGlyphs--;
|
||||||
|
@ -758,19 +773,20 @@ xglCachedGlyphs (CARD8 op,
|
||||||
pGlyphArea->u.box.sBox);
|
pGlyphArea->u.box.sBox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
count++;
|
|
||||||
}
|
}
|
||||||
remaining--;
|
remaining--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (depth != 1)
|
NEXT_GLYPH_SERIAL_NUMBER;
|
||||||
{
|
|
||||||
glitz_buffer_unmap (pGeometry->buffer);
|
|
||||||
pGeometry->count = count * 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count)
|
if (nGlyph)
|
||||||
{
|
{
|
||||||
|
if (depth != 1)
|
||||||
|
{
|
||||||
|
glitz_buffer_unmap (pGeometry->buffer);
|
||||||
|
pGeometry->count = nGlyph * 4;
|
||||||
|
}
|
||||||
|
|
||||||
xSrc += extents.x1;
|
xSrc += extents.x1;
|
||||||
ySrc += extents.y1;
|
ySrc += extents.y1;
|
||||||
|
|
||||||
|
@ -780,7 +796,7 @@ xglCachedGlyphs (CARD8 op,
|
||||||
pSrc = pScreenPriv->pSolidAlpha;
|
pSrc = pScreenPriv->pSolidAlpha;
|
||||||
|
|
||||||
if (remaining)
|
if (remaining)
|
||||||
*pOp = opSave;
|
*pOp = opSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
GEOMETRY_TRANSLATE (pGeometry,
|
GEOMETRY_TRANSLATE (pGeometry,
|
||||||
|
@ -805,15 +821,15 @@ xglCachedGlyphs (CARD8 op,
|
||||||
}
|
}
|
||||||
|
|
||||||
remaining = ~0;
|
remaining = ~0;
|
||||||
pOp->noCache = TRUE;
|
|
||||||
*pOp = opSave;
|
*pOp = opSave;
|
||||||
|
pOp->noCache = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (remaining)
|
if (remaining)
|
||||||
{
|
{
|
||||||
pOp->noCache = TRUE;
|
|
||||||
*pOp = opSave;
|
*pOp = opSave;
|
||||||
|
pOp->noCache = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue