xserver/render glyph.c, 1.7, 1.8 miglyph.c, 1.7, 1.8 mipict.c, 1.21,
1.22 picture.c, 1.37, 1.38
David Reveman
xserver-commit@pdx.freedesktop.org
Tue Jan 25 16:20:29 PST 2005
Committed by: davidr
Update of /cvs/xserver/xserver/render
In directory gabe:/tmp/cvs-serv26080/render
Modified Files:
glyph.c miglyph.c mipict.c picture.c
Log Message:
Add glyph privates
Index: glyph.c
===================================================================
RCS file: /cvs/xserver/xserver/render/glyph.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- glyph.c 11 Sep 2003 05:12:51 -0000 1.7
+++ glyph.c 26 Jan 2005 00:20:27 -0000 1.8
@@ -81,6 +81,281 @@
GlyphHashRec globalGlyphs[GlyphFormatNum];
+int globalTotalGlyphPrivateSize = 0;
+
+static int glyphPrivateCount = 0;
+
+void
+ResetGlyphPrivates ()
+{
+ glyphPrivateCount = 0;
+}
+
+int
+AllocateGlyphPrivateIndex ()
+{
+ return glyphPrivateCount++;
+}
+
+Bool
+AllocateGlyphPrivate (ScreenPtr pScreen,
+ int index2,
+ unsigned amount)
+{
+ PictureScreenPtr ps;
+ unsigned oldamount;
+
+ ps = GetPictureScreenIfSet (pScreen);
+ if (!ps)
+ return FALSE;
+
+ /* Round up sizes for proper alignment */
+ amount = ((amount + (sizeof (DevUnion) - 1)) / sizeof (DevUnion)) *
+ sizeof (DevUnion);
+
+ if (index2 >= ps->glyphPrivateLen)
+ {
+ unsigned *nsizes;
+ nsizes = (unsigned *) xrealloc (ps->glyphPrivateSizes,
+ (index2 + 1) * sizeof (unsigned));
+ if (!nsizes)
+ return FALSE;
+
+ while (ps->glyphPrivateLen <= index2)
+ {
+ nsizes[ps->glyphPrivateLen++] = 0;
+ ps->totalGlyphPrivateSize += sizeof (DevUnion);
+ }
+ ps->glyphPrivateSizes = nsizes;
+ }
+ oldamount = ps->glyphPrivateSizes[index2];
+ if (amount > oldamount)
+ {
+ ps->glyphPrivateSizes[index2] = amount;
+ ps->totalGlyphPrivateSize += (amount - oldamount);
+ }
+ ps->totalGlyphPrivateSize = BitmapBytePad (ps->totalGlyphPrivateSize * 8);
+
+ return TRUE;
+}
+
+static void
+SetGlyphScreenPrivateOffsets (void)
+{
+ PictureScreenPtr ps;
+ int offset = 0;
+ int i;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ ps = GetPictureScreenIfSet (screenInfo.screens[i]);
+ if (ps && ps->totalGlyphPrivateSize)
+ {
+ ps->glyphPrivateOffset = offset;
+ offset += ps->totalGlyphPrivateSize / sizeof (DevUnion);
+ }
+ }
+}
+
+static void
+SetGlyphPrivatePointers (GlyphPtr glyph)
+{
+ PictureScreenPtr ps;
+ int i;
+ char *ptr;
+ DevUnion *ppriv;
+ unsigned *sizes;
+ unsigned size;
+ int len;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ ps = GetPictureScreenIfSet (screenInfo.screens[i]);
+ if (ps && ps->totalGlyphPrivateSize)
+ {
+ ppriv = glyph->devPrivates + ps->glyphPrivateOffset;
+ sizes = ps->glyphPrivateSizes;
+ ptr = (char *) (ppriv + ps->glyphPrivateLen);
+ for (len = ps->glyphPrivateLen; --len >= 0; ppriv++, sizes++)
+ {
+ if ((size = *sizes) != 0)
+ {
+ ppriv->ptr = (pointer) ptr;
+ ptr += size;
+ }
+ else
+ ppriv->ptr = (pointer) 0;
+ }
+ }
+ }
+}
+
+static Bool
+ReallocGlobalGlyphPrivate (GlyphPtr glyph)
+{
+ PictureScreenPtr ps;
+ DevUnion *devPrivates;
+ char *ptr;
+ int i;
+
+ devPrivates = xalloc (globalTotalGlyphPrivateSize);
+ if (!devPrivates)
+ return FALSE;
+
+ ptr = (char *) devPrivates;
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ ps = GetPictureScreenIfSet (screenInfo.screens[i]);
+ if (ps && ps->totalGlyphPrivateSize)
+ {
+ if (ps->glyphPrivateOffset != -1)
+ {
+ memcpy (ptr, glyph->devPrivates + ps->glyphPrivateOffset,
+ ps->totalGlyphPrivateSize);
+ }
+ else if (ps->totalGlyphPrivateSize)
+ {
+ memset (ptr, 0, ps->totalGlyphPrivateSize);
+ }
+
+ ptr += ps->totalGlyphPrivateSize;
+ }
+ }
+
+ if (glyph->devPrivates)
+ xfree (glyph->devPrivates);
+
+ glyph->devPrivates = devPrivates;
+
+ return TRUE;
+}
+
+Bool
+GlyphInit (ScreenPtr pScreen)
+{
+ PictureScreenPtr ps = GetPictureScreen (pScreen);
+
+ ps->totalGlyphPrivateSize = 0;
+ ps->glyphPrivateSizes = 0;
+ ps->glyphPrivateLen = 0;
+ ps->glyphPrivateOffset = -1;
+
+ return TRUE;
+}
+
+Bool
+GlyphFinishInit (ScreenPtr pScreen)
+{
+ PictureScreenPtr ps = GetPictureScreen (pScreen);
+
+ if (ps->totalGlyphPrivateSize)
+ {
+ GlyphPtr glyph;
+ int fdepth, i;
+
+ globalTotalGlyphPrivateSize += ps->totalGlyphPrivateSize;
+
+ for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
+ {
+ if (!globalGlyphs[fdepth].hashSet)
+ continue;
+
+ for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
+ {
+ glyph = globalGlyphs[fdepth].table[i].glyph;
+ if (glyph && glyph != DeletedGlyph)
+ {
+ if (!ReallocGlobalGlyphPrivate (glyph))
+ return FALSE;
+ }
+ }
+ }
+
+ SetGlyphScreenPrivateOffsets ();
+
+ for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
+ {
+ if (!globalGlyphs[fdepth].hashSet)
+ continue;
+
+ for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
+ {
+ glyph = globalGlyphs[fdepth].table[i].glyph;
+ if (glyph && glyph != DeletedGlyph)
+ {
+ SetGlyphPrivatePointers (glyph);
+
+ if (!(*ps->RealizeGlyph) (pScreen, glyph))
+ return FALSE;
+ }
+ }
+ }
+ }
+ else
+ ps->glyphPrivateOffset = 0;
+
+ return TRUE;
+}
+
+void
+GlyphUninit (ScreenPtr pScreen)
+{
+ PictureScreenPtr ps = GetPictureScreen (pScreen);
+ GlyphPtr glyph;
+ int fdepth, i;
+
+ globalTotalGlyphPrivateSize -= ps->totalGlyphPrivateSize;
+
+ for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
+ {
+ if (!globalGlyphs[fdepth].hashSet)
+ continue;
+
+ for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
+ {
+ glyph = globalGlyphs[fdepth].table[i].glyph;
+ if (glyph && glyph != DeletedGlyph)
+ {
+ (*ps->UnrealizeGlyph) (pScreen, glyph);
+
+ if (globalTotalGlyphPrivateSize)
+ {
+ if (!ReallocGlobalGlyphPrivate (glyph))
+ return;
+ }
+ else
+ {
+ if (glyph->devPrivates)
+ xfree (glyph->devPrivates);
+ glyph->devPrivates = NULL;
+ }
+ }
+ }
+ }
+
+ if (globalTotalGlyphPrivateSize)
+ SetGlyphScreenPrivateOffsets ();
+
+ for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
+ {
+ if (!globalGlyphs[fdepth].hashSet)
+ continue;
+
+ for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
+ {
+ glyph = globalGlyphs[fdepth].table[i].glyph;
+ if (glyph && glyph != DeletedGlyph)
+ {
+ if (globalTotalGlyphPrivateSize)
+ SetGlyphPrivatePointers (glyph);
+ }
+ }
+ }
+
+ if (ps->glyphPrivateSizes)
+ xfree (ps->glyphPrivateSizes);
+}
+
GlyphHashSetPtr
FindGlyphHashSet (CARD32 filled)
{
@@ -92,12 +367,6 @@
return 0;
}
-Bool
-GlyphInit (ScreenPtr pScreen)
-{
- return TRUE;
-}
-
GlyphRefPtr
FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare)
{
@@ -194,9 +463,10 @@
CheckDuplicates (&globalGlyphs[format], "FreeGlyph");
if (--glyph->refcnt == 0)
{
- GlyphRefPtr gr;
- int i;
- int first;
+ PictureScreenPtr ps;
+ GlyphRefPtr gr;
+ int i;
+ int first;
first = -1;
for (i = 0; i < globalGlyphs[format].hashSet->size; i++)
@@ -217,6 +487,16 @@
gr->signature = 0;
globalGlyphs[format].tableEntries--;
}
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ ps = GetPictureScreenIfSet (screenInfo.screens[i]);
+ if (ps)
+ (*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
+ }
+
+ if (glyph->devPrivates)
+ xfree (glyph->devPrivates);
xfree (glyph);
}
}
@@ -287,8 +567,10 @@
GlyphPtr
AllocateGlyph (xGlyphInfo *gi, int fdepth)
{
- int size;
- GlyphPtr glyph;
+ PictureScreenPtr ps;
+ int size;
+ GlyphPtr glyph;
+ int i;
size = gi->height * PixmapBytePad (gi->width, glyphDepths[fdepth]);
glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec));
@@ -297,6 +579,39 @@
glyph->refcnt = 0;
glyph->size = size + sizeof (xGlyphInfo);
glyph->info = *gi;
+
+ if (globalTotalGlyphPrivateSize)
+ {
+ glyph->devPrivates = xalloc (globalTotalGlyphPrivateSize);
+ if (!glyph->devPrivates)
+ return 0;
+
+ SetGlyphPrivatePointers (glyph);
+ } else
+ glyph->devPrivates = NULL;
+
+ 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;
+ }
+ }
+ }
+
return glyph;
}
Index: miglyph.c
===================================================================
RCS file: /cvs/xserver/xserver/render/miglyph.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- miglyph.c 11 Sep 2003 05:12:51 -0000 1.7
+++ miglyph.c 26 Jan 2005 00:20:27 -0000 1.8
@@ -34,6 +34,19 @@
#include "picturestr.h"
#include "mipict.h"
+Bool
+miRealizeGlyph (ScreenPtr pScreen,
+ GlyphPtr glyph)
+{
+ return TRUE;
+}
+
+void
+miUnrealizeGlyph (ScreenPtr pScreen,
+ GlyphPtr glyph)
+{
+}
+
void
miGlyphExtents (int nlist,
GlyphListPtr list,
Index: mipict.c
===================================================================
RCS file: /cvs/xserver/xserver/render/mipict.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- mipict.c 4 Nov 2004 22:56:40 -0000 1.21
+++ mipict.c 26 Jan 2005 00:20:27 -0000 1.22
@@ -617,6 +617,9 @@
ps->UpdateIndexed = miUpdateIndexed;
ps->ChangePictureTransform = miChangePictureTransform;
ps->ChangePictureFilter = miChangePictureFilter;
+ ps->RealizeGlyph = miRealizeGlyph;
+ ps->UnrealizeGlyph = miUnrealizeGlyph;
+
/* MI rendering routines */
ps->Composite = 0; /* requires DDX support */
Index: picture.c
===================================================================
RCS file: /cvs/xserver/xserver/render/picture.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- picture.c 4 Nov 2004 22:56:40 -0000 1.37
+++ picture.c 26 Jan 2005 00:20:27 -0000 1.38
@@ -84,6 +84,7 @@
for (n = 0; n < ps->nformats; n++)
if (ps->formats[n].type == PictTypeIndexed)
(*ps->CloseIndexed) (pScreen, &ps->formats[n]);
+ GlyphUninit (pScreen);
SetPictureScreen(pScreen, 0);
xfree (ps->formats);
xfree (ps);
@@ -439,6 +440,8 @@
for (s = 0; s < screenInfo.numScreens; s++)
{
+ if (!GlyphFinishInit (screenInfo.screens[s]))
+ return FALSE;
if (!PictureInitIndexedFormats (screenInfo.screens[s]))
return FALSE;
(void) AnimCurInit (screenInfo.screens[s]);
More information about the xserver-commit
mailing list