mirror of
https://github.com/X11Libre/xserver.git
synced 2026-09-24 20:55:49 +00:00
Use per-screen Pixmaps for glyphs
Instead of system-memory data which prevents accelerated compositing of glyphs, (at least without forcing an upload of the glyph data before compositing).
This commit is contained in:
parent
19b3b1fd8f
commit
a2af34d5a8
6 changed files with 127 additions and 139 deletions
|
|
@ -571,9 +571,13 @@ FreeGlyph (GlyphPtr glyph, int format)
|
|||
|
||||
for (i = 0; i < screenInfo.numScreens; i++)
|
||||
{
|
||||
ps = GetPictureScreenIfSet (screenInfo.screens[i]);
|
||||
ScreenPtr pScreen = screenInfo.screens[i];
|
||||
|
||||
(pScreen->DestroyPixmap) (GlyphPixmap (glyph)[i]);
|
||||
|
||||
ps = GetPictureScreenIfSet (pScreen);
|
||||
if (ps)
|
||||
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
|
||||
(*ps->UnrealizeGlyph) (pScreen, glyph);
|
||||
}
|
||||
|
||||
if (glyph->devPrivates)
|
||||
|
|
@ -665,7 +669,7 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth)
|
|||
GlyphPtr glyph;
|
||||
int i;
|
||||
|
||||
size = gi->height * PixmapBytePad (gi->width, glyphDepths[fdepth]);
|
||||
size = screenInfo.numScreens * sizeof (PixmapPtr);
|
||||
glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec));
|
||||
if (!glyph)
|
||||
return 0;
|
||||
|
|
@ -685,27 +689,38 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth)
|
|||
|
||||
for (i = 0; i < screenInfo.numScreens; i++)
|
||||
{
|
||||
ps = GetPictureScreenIfSet (screenInfo.screens[i]);
|
||||
if (ps)
|
||||
{
|
||||
if (!(*ps->RealizeGlyph) (screenInfo.screens[i], glyph))
|
||||
{
|
||||
while (i--)
|
||||
{
|
||||
ps = GetPictureScreenIfSet (screenInfo.screens[i]);
|
||||
if (ps)
|
||||
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
|
||||
}
|
||||
|
||||
if (glyph->devPrivates)
|
||||
xfree (glyph->devPrivates);
|
||||
xfree (glyph);
|
||||
return 0;
|
||||
}
|
||||
ScreenPtr pScreen = screenInfo.screens[i];
|
||||
|
||||
GlyphPixmap (glyph)[i] = (pScreen->CreatePixmap) (pScreen,
|
||||
gi->width, gi->height,
|
||||
glyphDepths[fdepth]);
|
||||
if (! GlyphPixmap (glyph)[i])
|
||||
goto bail;
|
||||
|
||||
ps = GetPictureScreenIfSet (pScreen);
|
||||
if (! ps)
|
||||
continue;
|
||||
|
||||
if (!(*ps->RealizeGlyph) (pScreen, glyph)) {
|
||||
(pScreen->DestroyPixmap) (GlyphPixmap (glyph)[i]);
|
||||
goto bail;
|
||||
}
|
||||
}
|
||||
|
||||
return glyph;
|
||||
|
||||
bail:
|
||||
while (i--)
|
||||
{
|
||||
ps = GetPictureScreenIfSet (screenInfo.screens[i]);
|
||||
if (ps)
|
||||
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
|
||||
}
|
||||
|
||||
if (glyph->devPrivates)
|
||||
xfree (glyph->devPrivates);
|
||||
xfree (glyph);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Bool
|
||||
|
|
|
|||
|
|
@ -44,9 +44,11 @@ typedef struct _Glyph {
|
|||
unsigned char sha1[20];
|
||||
CARD32 size; /* info + bitmap */
|
||||
xGlyphInfo info;
|
||||
/* bits follow */
|
||||
/* per-screen pixmaps follow */
|
||||
} GlyphRec, *GlyphPtr;
|
||||
|
||||
#define GlyphPixmap(glyph) ((PixmapPtr *) ((glyph) + 1))
|
||||
|
||||
typedef struct _GlyphRef {
|
||||
CARD32 signature;
|
||||
GlyphPtr glyph;
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ miGlyphs (CARD8 op,
|
|||
GlyphListPtr list,
|
||||
GlyphPtr *glyphs)
|
||||
{
|
||||
PixmapPtr pPixmap = 0;
|
||||
PixmapPtr pPixmap;
|
||||
PicturePtr pPicture;
|
||||
PixmapPtr pMaskPixmap = 0;
|
||||
PicturePtr pMask;
|
||||
|
|
@ -166,7 +166,6 @@ miGlyphs (CARD8 op,
|
|||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
pPicture = 0;
|
||||
while (nlist--)
|
||||
{
|
||||
x += list->xOff;
|
||||
|
|
@ -175,28 +174,14 @@ miGlyphs (CARD8 op,
|
|||
while (n--)
|
||||
{
|
||||
glyph = *glyphs++;
|
||||
pPixmap = GlyphPixmap (glyph)[pScreen->myNum];
|
||||
component_alpha = NeedsComponent(list->format->format);
|
||||
pPicture = CreatePicture (0, &pPixmap->drawable, list->format,
|
||||
CPComponentAlpha, &component_alpha,
|
||||
serverClient, &error);
|
||||
if (!pPicture)
|
||||
{
|
||||
pPixmap = GetScratchPixmapHeader (pScreen, glyph->info.width, glyph->info.height,
|
||||
list->format->depth,
|
||||
list->format->depth,
|
||||
0, (pointer) (glyph + 1));
|
||||
if (!pPixmap)
|
||||
return;
|
||||
component_alpha = NeedsComponent(list->format->format);
|
||||
pPicture = CreatePicture (0, &pPixmap->drawable, list->format,
|
||||
CPComponentAlpha, &component_alpha,
|
||||
serverClient, &error);
|
||||
if (!pPicture)
|
||||
{
|
||||
FreeScratchPixmapHeader (pPixmap);
|
||||
return;
|
||||
}
|
||||
}
|
||||
(*pScreen->ModifyPixmapHeader) (pPixmap,
|
||||
glyph->info.width, glyph->info.height,
|
||||
0, 0, -1, (pointer) (glyph + 1));
|
||||
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
||||
return;
|
||||
|
||||
if (maskFormat)
|
||||
{
|
||||
CompositePicture (PictOpAdd,
|
||||
|
|
@ -224,17 +209,12 @@ miGlyphs (CARD8 op,
|
|||
glyph->info.width,
|
||||
glyph->info.height);
|
||||
}
|
||||
FreePicture ((pointer) pPicture, 0);
|
||||
|
||||
x += glyph->info.xOff;
|
||||
y += glyph->info.yOff;
|
||||
}
|
||||
list++;
|
||||
if (pPicture)
|
||||
{
|
||||
FreeScratchPixmapHeader (pPixmap);
|
||||
FreePicture ((pointer) pPicture, 0);
|
||||
pPicture = 0;
|
||||
pPixmap = 0;
|
||||
}
|
||||
}
|
||||
if (maskFormat)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1099,7 +1099,9 @@ ProcRenderAddGlyphs (ClientPtr client)
|
|||
CARD8 *bits;
|
||||
int size;
|
||||
int err = BadAlloc;
|
||||
int i;
|
||||
int i, screen;
|
||||
PicturePtr pSrc = NULL, pDst = NULL;
|
||||
PixmapPtr pSrcPix = NULL, pDstPix = NULL;
|
||||
|
||||
REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
|
||||
glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
|
||||
|
|
@ -1164,7 +1166,62 @@ ProcRenderAddGlyphs (ClientPtr client)
|
|||
goto bail;
|
||||
}
|
||||
|
||||
memcpy ((CARD8 *) (glyph_new->glyph + 1), bits, size);
|
||||
for (screen = 0; screen < screenInfo.numScreens; screen++)
|
||||
{
|
||||
int width = gi[i].width;
|
||||
int height = gi[i].height;
|
||||
int depth = glyphSet->format->depth;
|
||||
ScreenPtr pScreen;
|
||||
int error;
|
||||
|
||||
pScreen = screenInfo.screens[screen];
|
||||
pSrcPix = GetScratchPixmapHeader (pScreen,
|
||||
width, height,
|
||||
depth, depth,
|
||||
-1, bits);
|
||||
if (! pSrcPix)
|
||||
{
|
||||
err = BadAlloc;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
pSrc = CreatePicture (0, &pSrcPix->drawable,
|
||||
glyphSet->format, 0, NULL,
|
||||
serverClient, &error);
|
||||
if (! pSrc)
|
||||
{
|
||||
err = BadAlloc;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
pDstPix = GlyphPixmap (glyph_new->glyph)[screen];
|
||||
|
||||
pDst = CreatePicture (0, &pDstPix->drawable,
|
||||
glyphSet->format, 0, NULL,
|
||||
serverClient, &error);
|
||||
if (! pDst)
|
||||
{
|
||||
err = BadAlloc;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
CompositePicture (PictOpSrc,
|
||||
pSrc,
|
||||
None,
|
||||
pDst,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
width, height);
|
||||
|
||||
FreePicture ((pointer) pSrc, 0);
|
||||
pSrc = NULL;
|
||||
FreePicture ((pointer) pDst, 0);
|
||||
pDst = NULL;
|
||||
FreeScratchPixmapHeader (pSrcPix);
|
||||
pSrcPix = NULL;
|
||||
}
|
||||
|
||||
memcpy (glyph_new->glyph->sha1, glyph_new->sha1, 20);
|
||||
}
|
||||
|
||||
|
|
@ -1192,6 +1249,12 @@ ProcRenderAddGlyphs (ClientPtr client)
|
|||
Xfree (glyphsBase);
|
||||
return client->noClientException;
|
||||
bail:
|
||||
if (pSrc)
|
||||
FreePicture ((pointer) pSrc, 0);
|
||||
if (pDst)
|
||||
FreePicture ((pointer) pDst, 0);
|
||||
if (pSrcPix)
|
||||
FreeScratchPixmapHeader (pSrcPix);
|
||||
for (i = 0; i < nglyphs; i++)
|
||||
if (glyphs[i].glyph && ! glyphs[i].found)
|
||||
xfree (glyphs[i].glyph);
|
||||
|
|
|
|||
Loading…
Reference in a new issue