Store glyph data in glyph private so we don't have to fetch it from a back-end server when attaching a new screen.

This commit is contained in:
David Reveman 2008-07-16 19:40:58 -04:00
parent 7ea245b7a4
commit fa53ca5772
5 changed files with 87 additions and 31 deletions

View file

@ -292,6 +292,9 @@ typedef struct _DMXScreenInfo {
TrianglesProcPtr Triangles; TrianglesProcPtr Triangles;
TriStripProcPtr TriStrip; TriStripProcPtr TriStrip;
TriFanProcPtr TriFan; TriFanProcPtr TriFan;
RealizeGlyphProcPtr RealizeGlyph;
UnrealizeGlyphProcPtr UnrealizeGlyph;
#endif #endif
} DMXScreenInfo; } DMXScreenInfo;

View file

@ -1649,7 +1649,7 @@ static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
char *pos; char *pos;
int beret; int beret;
int len_images = 0; int len_images = 0;
int i, j, size; int i, size;
int ctr; int ctr;
if (glyphPriv->glyphSets[scrnNum]) { if (glyphPriv->glyphSets[scrnNum]) {
@ -1697,7 +1697,7 @@ static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
for (i = 0; i < glyphSet->hash.hashSet->size; i++) { for (i = 0; i < glyphSet->hash.hashSet->size; i++) {
GlyphRefPtr gr = &table[i]; GlyphRefPtr gr = &table[i];
GlyphPtr gl = gr->glyph; GlyphPtr gl = gr->glyph;
XImage *img = NULL; char *data;
if (!gl || gl == DeletedGlyph) continue; if (!gl || gl == DeletedGlyph) continue;
@ -1712,38 +1712,15 @@ static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
glyphs[ctr].xOff = gl->info.xOff; glyphs[ctr].xOff = gl->info.xOff;
glyphs[ctr].yOff = gl->info.yOff; glyphs[ctr].yOff = gl->info.yOff;
for (j = 0; j < dmxNumScreens; j++)
{
if (j != scrnNum && dmxScreens[j].alive)
{
PicturePtr pPict = GlyphPicture (gl)[j];
PixmapPtr pPixmap = (PixmapPtr) pPict->pDrawable;
dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV (pPixmap);
XLIB_PROLOGUE (&dmxScreens[j]);
img = XGetImage (dmxScreens[j].beDisplay,
pPixPriv->pixmap,
0, 0,
pPixmap->drawable.width,
pPixmap->drawable.height,
-1,
ZPixmap);
XLIB_EPILOGUE (&dmxScreens[j]);
if (img)
break;
}
}
size = gl->info.height * PixmapBytePad (gl->info.width, size = gl->info.height * PixmapBytePad (gl->info.width,
glyphSet->format->depth); glyphSet->format->depth);
if (size & 3) if (size & 3)
size += 4 - (size & 3); size += 4 - (size & 3);
if (img) data = dixLookupPrivate (&(gl)->devPrivates, dmxGlyphPrivateKey);
if (data)
{ {
memcpy (pos, img->data, size); memcpy (pos, data, size);
XDestroyImage (img);
} }
else else
{ {

View file

@ -103,6 +103,46 @@ dmxFreeGlyphSet (pointer value,
return FreeGlyphSet (value, gid); return FreeGlyphSet (value, gid);
} }
static Bool
dmxRealizeGlyph (ScreenPtr pScreen,
GlyphPtr glyph)
{
PictureScreenPtr ps = GetPictureScreen (pScreen);
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
int ret;
if (pScreen->myNum == 0)
*((PrivateRec **) dixLookupPrivateAddr (&(glyph)->devPrivates,
dmxGlyphPrivateKey)) = NULL;
DMX_UNWRAP (RealizeGlyph, dmxScreen, ps);
ret = (*ps->RealizeGlyph) (pScreen, glyph);
DMX_WRAP (RealizeGlyph, dmxRealizeGlyph, dmxScreen, ps);
return ret;
}
static void
dmxUnrealizeGlyph (ScreenPtr pScreen,
GlyphPtr glyph)
{
PictureScreenPtr ps = GetPictureScreen (pScreen);
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
if (pScreen->myNum == 0)
{
char *data;
data = dixLookupPrivate (&(glyph)->devPrivates, dmxGlyphPrivateKey);
if (data)
xfree (data);
}
DMX_UNWRAP (UnrealizeGlyph, dmxScreen, ps);
(*ps->UnrealizeGlyph) (pScreen, glyph);
DMX_WRAP (UnrealizeGlyph, dmxUnrealizeGlyph, dmxScreen, ps);
}
/** Initialize the Proc Vector for the RENDER extension. The functions /** Initialize the Proc Vector for the RENDER extension. The functions
* here cannot be handled by the mi layer RENDER hooks either because * here cannot be handled by the mi layer RENDER hooks either because
* the required information is no longer available when it reaches the * the required information is no longer available when it reaches the
@ -412,6 +452,9 @@ Bool dmxPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
if (!dixRequestPrivate(dmxGlyphSetPrivateKey, sizeof(dmxGlyphPrivRec))) if (!dixRequestPrivate(dmxGlyphSetPrivateKey, sizeof(dmxGlyphPrivRec)))
return FALSE; return FALSE;
if (!dixRequestPrivate(dmxGlyphPrivateKey, 0))
return FALSE;
ps = GetPictureScreen(pScreen); ps = GetPictureScreen(pScreen);
DMX_WRAP(CreatePicture, dmxCreatePicture, dmxScreen, ps); DMX_WRAP(CreatePicture, dmxCreatePicture, dmxScreen, ps);
@ -432,6 +475,9 @@ Bool dmxPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
DMX_WRAP(TriStrip, dmxTriStrip, dmxScreen, ps); DMX_WRAP(TriStrip, dmxTriStrip, dmxScreen, ps);
DMX_WRAP(TriFan, dmxTriFan, dmxScreen, ps); DMX_WRAP(TriFan, dmxTriFan, dmxScreen, ps);
DMX_WRAP(RealizeGlyph, dmxRealizeGlyph, dmxScreen, ps);
DMX_WRAP(UnrealizeGlyph, dmxUnrealizeGlyph, dmxScreen, ps);
return TRUE; return TRUE;
} }
@ -596,7 +642,8 @@ static int dmxProcRenderAddGlyphs(ClientPtr client)
Glyph *gidsCopy; Glyph *gidsCopy;
xGlyphInfo *gi; xGlyphInfo *gi;
CARD8 *bits; CARD8 *bits;
int nbytes; int nbytes, size;
void *data;
glyphSet = SecurityLookupIDByType(client, stuff->glyphset, glyphSet = SecurityLookupIDByType(client, stuff->glyphset,
GlyphSetType, DixReadAccess); GlyphSetType, DixReadAccess);
@ -611,7 +658,34 @@ static int dmxProcRenderAddGlyphs(ClientPtr client)
(sizeof(CARD32) + sizeof(xGlyphInfo)) * nglyphs); (sizeof(CARD32) + sizeof(xGlyphInfo)) * nglyphs);
gidsCopy = xalloc(sizeof(*gidsCopy) * nglyphs); gidsCopy = xalloc(sizeof(*gidsCopy) * nglyphs);
for (i = 0; i < nglyphs; i++) gidsCopy[i] = gids[i]; for (i = 0; i < nglyphs; i++)
{
GlyphPtr glyph;
gidsCopy[i] = gids[i];
size = gi[i].height * PixmapBytePad (gi[i].width,
glyphSet->format->depth);
if (size & 3)
size += 4 - (size & 3);
glyph = FindGlyph (glyphSet, gids[i]);
if (glyph)
{
data = xalloc (size);
if (data)
{
memcpy (data, bits, size);
*((PrivateRec **)
dixLookupPrivateAddr (&(glyph)->devPrivates,
dmxGlyphPrivateKey)) = data;
}
}
bits += size;
}
bits = (CARD8 *)(gi + nglyphs);
/* FIXME: Will this ever fail? */ /* FIXME: Will this ever fail? */
for (i = 0; i < dmxNumScreens; i++) { for (i = 0; i < dmxNumScreens; i++) {

View file

@ -118,7 +118,7 @@ extern Bool dmxBEFreePicture(PicturePtr pPicture);
extern DevPrivateKey dmxPictPrivateKey; /**< Index for picture private data */ extern DevPrivateKey dmxPictPrivateKey; /**< Index for picture private data */
extern DevPrivateKey dmxGlyphSetPrivateKey; /**< Index for glyphset private data */ extern DevPrivateKey dmxGlyphSetPrivateKey; /**< Index for glyphset private data */
extern DevPrivateKey dmxGlyphPrivateKey; /**< Index for glyph private data */
/** Get the picture private data given a picture pointer */ /** Get the picture private data given a picture pointer */
#define DMX_GET_PICT_PRIV(_pPict) \ #define DMX_GET_PICT_PRIV(_pPict) \

View file

@ -141,6 +141,8 @@ static int dmxPictPrivateKeyIndex;
DevPrivateKey dmxPictPrivateKey = &dmxPictPrivateKeyIndex; /**< Private index for Picts */ DevPrivateKey dmxPictPrivateKey = &dmxPictPrivateKeyIndex; /**< Private index for Picts */
static int dmxGlyphSetPrivateKeyIndex; static int dmxGlyphSetPrivateKeyIndex;
DevPrivateKey dmxGlyphSetPrivateKey = &dmxGlyphSetPrivateKeyIndex; /**< Private index for GlyphSets */ DevPrivateKey dmxGlyphSetPrivateKey = &dmxGlyphSetPrivateKeyIndex; /**< Private index for GlyphSets */
static int dmxGlyphPrivateKeyIndex;
DevPrivateKey dmxGlyphPrivateKey = &dmxGlyphPrivateKeyIndex; /**< Private index for Glyphs */
#endif #endif
#ifdef RANDR #ifdef RANDR