From 7976ee51afcad41b611e642d2feb31d805dedcf6 Mon Sep 17 00:00:00 2001 From: Kevin E Martin Date: Wed, 30 Jun 2004 20:06:56 +0000 Subject: Add Distributed Multihead X (DMX) support --- render/glyph.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++- render/glyphstr.h | 21 +++++++++++++++++++ render/picture.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ render/picturestr.h | 11 +++++++++- render/render.c | 4 +++- 5 files changed, 146 insertions(+), 3 deletions(-) (limited to 'render') diff --git a/render/glyph.c b/render/glyph.c index 5dd700581..e4c2f689e 100644 --- a/render/glyph.c +++ b/render/glyph.c @@ -89,6 +89,50 @@ FindGlyphHashSet (CARD32 filled) return 0; } +static int _GlyphSetPrivateAllocateIndex = 0; + +int +AllocateGlyphSetPrivateIndex (void) +{ + return _GlyphSetPrivateAllocateIndex++; +} + +void +ResetGlyphSetPrivateIndex (void) +{ + _GlyphSetPrivateAllocateIndex = 0; +} + +Bool +_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr) +{ + pointer *new; + + if (n > glyphSet->maxPrivate) { + if (glyphSet->devPrivates && + glyphSet->devPrivates != (pointer)(&glyphSet[1])) { + new = (pointer *) xrealloc (glyphSet->devPrivates, + (n + 1) * sizeof (pointer)); + if (!new) + return FALSE; + } else { + new = (pointer *) xalloc ((n + 1) * sizeof (pointer)); + if (!new) + return FALSE; + if (glyphSet->devPrivates) + memcpy (new, + glyphSet->devPrivates, + (glyphSet->maxPrivate + 1) * sizeof (pointer)); + } + glyphSet->devPrivates = new; + /* Zero out new, uninitialize privates */ + while (++glyphSet->maxPrivate < n) + glyphSet->devPrivates[glyphSet->maxPrivate] = (pointer)0; + } + glyphSet->devPrivates[n] = ptr; + return TRUE; +} + Bool GlyphInit (ScreenPtr pScreen) { @@ -363,15 +407,24 @@ GlyphSetPtr AllocateGlyphSet (int fdepth, PictFormatPtr format) { GlyphSetPtr glyphSet; + int size; if (!globalGlyphs[fdepth].hashSet) { if (!AllocateGlyphHash (&globalGlyphs[fdepth], &glyphHashSets[0])) return FALSE; } - glyphSet = xalloc (sizeof (GlyphSetRec)); + + size = (sizeof (GlyphSetRec) + + (sizeof (pointer) * _GlyphSetPrivateAllocateIndex)); + glyphSet = xalloc (size); if (!glyphSet) return FALSE; + bzero((char *)glyphSet, size); + glyphSet->maxPrivate = _GlyphSetPrivateAllocateIndex - 1; + if (_GlyphSetPrivateAllocateIndex) + glyphSet->devPrivates = (pointer)(&glyphSet[1]); + if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0])) { xfree (glyphSet); @@ -410,6 +463,11 @@ FreeGlyphSet (pointer value, else ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE); xfree (table); + + if (glyphSet->devPrivates && + glyphSet->devPrivates != (pointer)(&glyphSet[1])) + xfree(glyphSet->devPrivates); + xfree (glyphSet); } return Success; diff --git a/render/glyphstr.h b/render/glyphstr.h index 68d6f2085..0f496d704 100644 --- a/render/glyphstr.h +++ b/render/glyphstr.h @@ -68,8 +68,20 @@ typedef struct _GlyphSet { PictFormatPtr format; int fdepth; GlyphHashRec hash; + int maxPrivate; + pointer *devPrivates; } GlyphSetRec, *GlyphSetPtr; +#define GlyphSetGetPrivate(pGlyphSet,n) \ + ((n) > (pGlyphSet)->maxPrivate ? \ + (pointer) 0 : \ + (pGlyphSet)->devPrivates[n]) + +#define GlyphSetSetPrivate(pGlyphSet,n,ptr) \ + ((n) > (pGlyphSet)->maxPrivate ? \ + _GlyphSetSetNewPrivate(pGlyphSet, n, ptr) : \ + ((((pGlyphSet)->devPrivates[n] = (ptr)) != 0) || TRUE)) + typedef struct _GlyphList { INT16 xOff; INT16 yOff; @@ -82,6 +94,15 @@ extern GlyphHashRec globalGlyphs[GlyphFormatNum]; GlyphHashSetPtr FindGlyphHashSet (CARD32 filled); +int +AllocateGlyphSetPrivateIndex (void); + +void +ResetGlyphSetPrivateIndex (void); + +Bool +_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr); + Bool GlyphInit (ScreenPtr pScreen); diff --git a/render/picture.c b/render/picture.c index ad746b277..ca95e56b2 100644 --- a/render/picture.c +++ b/render/picture.c @@ -46,6 +46,57 @@ RESTYPE PictFormatType; RESTYPE GlyphSetType; int PictureCmapPolicy = PictureCmapPolicyDefault; +/* Picture Private machinery */ + +static int picturePrivateCount; + +void +ResetPicturePrivateIndex (void) +{ + picturePrivateCount = 0; +} + +int +AllocatePicturePrivateIndex (void) +{ + return picturePrivateCount++; +} + +Bool +AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount) +{ + PictureScreenPtr ps = GetPictureScreen(pScreen); + unsigned int oldamount; + + /* Round up sizes for proper alignment */ + amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); + + if (index2 >= ps->PicturePrivateLen) + { + unsigned int *nsizes; + + nsizes = (unsigned int *)xrealloc(ps->PicturePrivateSizes, + (index2 + 1) * sizeof(unsigned int)); + if (!nsizes) + return FALSE; + while (ps->PicturePrivateLen <= index2) + { + nsizes[ps->PicturePrivateLen++] = 0; + ps->totalPictureSize += sizeof(DevUnion); + } + ps->PicturePrivateSizes = nsizes; + } + oldamount = ps->PicturePrivateSizes[index2]; + if (amount > oldamount) + { + ps->PicturePrivateSizes[index2] = amount; + ps->totalPictureSize += (amount - oldamount); + } + + return TRUE; +} + + Bool PictureDestroyWindow (WindowPtr pWindow) { @@ -82,6 +133,8 @@ PictureCloseScreen (int index, ScreenPtr pScreen) if (ps->formats[n].type == PictTypeIndexed) (*ps->CloseIndexed) (pScreen, &ps->formats[n]); SetPictureScreen(pScreen, 0); + if (ps->PicturePrivateSizes) + xfree (ps->PicturePrivateSizes); xfree (ps->formats); xfree (ps); return ret; diff --git a/render/picturestr.h b/render/picturestr.h index 04b6a3d78..bce59f532 100644 --- a/render/picturestr.h +++ b/render/picturestr.h @@ -1,4 +1,4 @@ -/* $XdotOrg$ */ +/* $XdotOrg: xc/programs/Xserver/render/picturestr.h,v 1.2 2004/04/23 19:54:29 eich Exp $ */ /* * $XFree86: xc/programs/Xserver/render/picturestr.h,v 1.21 2002/11/06 22:45:36 keithp Exp $ * @@ -303,6 +303,15 @@ extern RESTYPE GlyphSetType; } \ } \ +void +ResetPicturePrivateIndex (void); + +int +AllocatePicturePrivateIndex (void); + +Bool +AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount); + Bool PictureDestroyWindow (WindowPtr pWindow); diff --git a/render/render.c b/render/render.c index e35c52542..d490b01c5 100644 --- a/render/render.c +++ b/render/render.c @@ -1,4 +1,4 @@ -/* $XdotOrg$ */ +/* $XdotOrg: xc/programs/Xserver/render/render.c,v 1.2 2004/04/23 19:54:29 eich Exp $ */ /* * $XFree86: xc/programs/Xserver/render/render.c,v 1.27tsi Exp $ * @@ -243,6 +243,8 @@ RenderExtensionInit (void) static void RenderResetProc (ExtensionEntry *extEntry) { + ResetPicturePrivateIndex(); + ResetGlyphSetPrivateIndex(); } static int -- cgit v1.2.3