From fa53ca5772bd95838bbdda6074cb357f7a68dbbd Mon Sep 17 00:00:00 2001 From: David Reveman Date: Wed, 16 Jul 2008 19:40:58 -0400 Subject: [PATCH] Store glyph data in glyph private so we don't have to fetch it from a back-end server when attaching a new screen. --- hw/dmx/dmx.h | 3 ++ hw/dmx/dmxextension.c | 33 +++--------------- hw/dmx/dmxpict.c | 78 +++++++++++++++++++++++++++++++++++++++++-- hw/dmx/dmxpict.h | 2 +- hw/dmx/dmxscrinit.c | 2 ++ 5 files changed, 87 insertions(+), 31 deletions(-) diff --git a/hw/dmx/dmx.h b/hw/dmx/dmx.h index 809debcde..96727c3e2 100644 --- a/hw/dmx/dmx.h +++ b/hw/dmx/dmx.h @@ -292,6 +292,9 @@ typedef struct _DMXScreenInfo { TrianglesProcPtr Triangles; TriStripProcPtr TriStrip; TriFanProcPtr TriFan; + + RealizeGlyphProcPtr RealizeGlyph; + UnrealizeGlyphProcPtr UnrealizeGlyph; #endif } DMXScreenInfo; diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c index b84cfdd4c..fafd3504d 100644 --- a/hw/dmx/dmxextension.c +++ b/hw/dmx/dmxextension.c @@ -1649,7 +1649,7 @@ static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n) char *pos; int beret; int len_images = 0; - int i, j, size; + int i, size; int ctr; 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++) { GlyphRefPtr gr = &table[i]; GlyphPtr gl = gr->glyph; - XImage *img = NULL; + char *data; 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].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, glyphSet->format->depth); if (size & 3) size += 4 - (size & 3); - if (img) + data = dixLookupPrivate (&(gl)->devPrivates, dmxGlyphPrivateKey); + if (data) { - memcpy (pos, img->data, size); - XDestroyImage (img); + memcpy (pos, data, size); } else { diff --git a/hw/dmx/dmxpict.c b/hw/dmx/dmxpict.c index 6ec3676ee..e84d0ffa4 100644 --- a/hw/dmx/dmxpict.c +++ b/hw/dmx/dmxpict.c @@ -103,6 +103,46 @@ dmxFreeGlyphSet (pointer value, 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 * here cannot be handled by the mi layer RENDER hooks either because * 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))) return FALSE; + if (!dixRequestPrivate(dmxGlyphPrivateKey, 0)) + return FALSE; + ps = GetPictureScreen(pScreen); 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(TriFan, dmxTriFan, dmxScreen, ps); + DMX_WRAP(RealizeGlyph, dmxRealizeGlyph, dmxScreen, ps); + DMX_WRAP(UnrealizeGlyph, dmxUnrealizeGlyph, dmxScreen, ps); + return TRUE; } @@ -596,7 +642,8 @@ static int dmxProcRenderAddGlyphs(ClientPtr client) Glyph *gidsCopy; xGlyphInfo *gi; CARD8 *bits; - int nbytes; + int nbytes, size; + void *data; glyphSet = SecurityLookupIDByType(client, stuff->glyphset, GlyphSetType, DixReadAccess); @@ -611,7 +658,34 @@ static int dmxProcRenderAddGlyphs(ClientPtr client) (sizeof(CARD32) + sizeof(xGlyphInfo)) * 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? */ for (i = 0; i < dmxNumScreens; i++) { diff --git a/hw/dmx/dmxpict.h b/hw/dmx/dmxpict.h index c7e913448..0930d5c7e 100644 --- a/hw/dmx/dmxpict.h +++ b/hw/dmx/dmxpict.h @@ -118,7 +118,7 @@ extern Bool dmxBEFreePicture(PicturePtr pPicture); extern DevPrivateKey dmxPictPrivateKey; /**< Index for picture 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 */ #define DMX_GET_PICT_PRIV(_pPict) \ diff --git a/hw/dmx/dmxscrinit.c b/hw/dmx/dmxscrinit.c index 2bf1ef741..560a3e6e0 100644 --- a/hw/dmx/dmxscrinit.c +++ b/hw/dmx/dmxscrinit.c @@ -141,6 +141,8 @@ static int dmxPictPrivateKeyIndex; DevPrivateKey dmxPictPrivateKey = &dmxPictPrivateKeyIndex; /**< Private index for Picts */ static int dmxGlyphSetPrivateKeyIndex; DevPrivateKey dmxGlyphSetPrivateKey = &dmxGlyphSetPrivateKeyIndex; /**< Private index for GlyphSets */ +static int dmxGlyphPrivateKeyIndex; +DevPrivateKey dmxGlyphPrivateKey = &dmxGlyphPrivateKeyIndex; /**< Private index for Glyphs */ #endif #ifdef RANDR