summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-04-26 17:22:21 -0700
committerKeith Packard <keithp@keithp.com>2010-06-05 19:23:03 -0700
commitfaeebead7bfcc78535757ca7acc1faf7554c03b7 (patch)
tree1a8f13a3b1ae968011efb9679bc3ed79a29020be /render
parentc865a24401f06bcf1347d8b41f736a066ab25693 (diff)
Change the devPrivates API to require dixRegisterPrivateKey
This patch only changes the API, not the implementation of the devPrivates infrastructure. This will permit a new devPrivates implementation to be layed into the server without requiring simultaneous changes in every devPrivates user. Signed-off-by: Keith Packard <keithp@keithp.com> Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Diffstat (limited to 'render')
-rw-r--r--render/animcur.c19
-rw-r--r--render/glyph.c36
-rw-r--r--render/picture.c21
-rw-r--r--render/picture.h1
-rw-r--r--render/picturestr.h8
-rw-r--r--render/render.c6
6 files changed, 46 insertions, 45 deletions
diff --git a/render/animcur.c b/render/animcur.c
index ad126fb48..2160f5043 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -76,11 +76,11 @@ static CursorBits animCursorBits = {
empty, empty, 2, 1, 1, 0, 0, 1
};
-static int AnimCurScreenPrivateKeyIndex;
-static DevPrivateKey AnimCurScreenPrivateKey = &AnimCurScreenPrivateKeyIndex;
+static DevPrivateKeyRec AnimCurScreenPrivateKeyRec;
+#define AnimCurScreenPrivateKey (&AnimCurScreenPrivateKeyRec)
#define IsAnimCur(c) ((c) && ((c)->bits == &animCursorBits))
-#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
+#define GetAnimCur(c) ((AnimCurPtr) ((((char *)(c) + CURSOR_REC_SIZE))))
#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey))
#define SetAnimCurScreen(s,p) dixSetPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey, p)
@@ -322,6 +322,9 @@ AnimCurInit (ScreenPtr pScreen)
{
AnimCurScreenPtr as;
+ if (!dixRegisterPrivateKey(&AnimCurScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
as = (AnimCurScreenPtr) malloc(sizeof (AnimCurScreenRec));
if (!as)
return FALSE;
@@ -354,11 +357,12 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
if (IsAnimCur (cursors[i]))
return BadMatch;
- pCursor = (CursorPtr) malloc(sizeof (CursorRec) +
- sizeof (AnimCurRec) +
- ncursor * sizeof (AnimCurElt));
+ pCursor = (CursorPtr) calloc(CURSOR_REC_SIZE +
+ sizeof (AnimCurRec) +
+ ncursor * sizeof (AnimCurElt), 1);
if (!pCursor)
return BadAlloc;
+ dixInitPrivates(pCursor, pCursor + 1, PRIVATE_CURSOR);
pCursor->bits = &animCursorBits;
pCursor->refcnt = 1;
@@ -371,13 +375,12 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
pCursor->backBlue = cursors[0]->backBlue;
pCursor->id = cid;
- pCursor->devPrivates = NULL;
/* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, pCursor,
RT_NONE, NULL, DixCreateAccess);
if (rc != Success) {
- dixFreePrivates(pCursor->devPrivates);
+ dixFiniPrivates(pCursor, PRIVATE_CURSOR);
free(pCursor);
return rc;
}
diff --git a/render/glyph.c b/render/glyph.c
index e5b8f8633..948a20a9a 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -84,19 +84,13 @@ static const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
static GlyphHashRec globalGlyphs[GlyphFormatNum];
-static void
-FreeGlyphPrivates (GlyphPtr glyph)
-{
- dixFreePrivates(glyph->devPrivates);
- glyph->devPrivates = NULL;
-}
-
void
GlyphUninit (ScreenPtr pScreen)
{
PictureScreenPtr ps = GetPictureScreen (pScreen);
GlyphPtr glyph;
int fdepth, i;
+ int scrno = pScreen->myNum;
for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
{
@@ -108,8 +102,12 @@ GlyphUninit (ScreenPtr pScreen)
glyph = globalGlyphs[fdepth].table[i].glyph;
if (glyph && glyph != DeletedGlyph)
{
+ if (GlyphPicture(glyph)[scrno])
+ {
+ FreePicture ((pointer) GlyphPicture (glyph)[scrno], 0);
+ GlyphPicture(glyph)[scrno] = NULL;
+ }
(*ps->UnrealizeGlyph) (pScreen, glyph);
- FreeGlyphPrivates(glyph);
}
}
}
@@ -301,8 +299,7 @@ FreeGlyph (GlyphPtr glyph, int format)
}
FreeGlyphPicture(glyph);
- FreeGlyphPrivates(glyph);
- free(glyph);
+ dixFreeObjectWithPrivates(glyph, PRIVATE_GLYPH);
}
}
@@ -320,8 +317,7 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
if (gr->glyph && gr->glyph != DeletedGlyph && gr->glyph != glyph)
{
FreeGlyphPicture(glyph);
- FreeGlyphPrivates(glyph);
- free(glyph);
+ dixFreeObjectWithPrivates(glyph, PRIVATE_GLYPH);
glyph = gr->glyph;
}
else if (gr->glyph != glyph)
@@ -372,6 +368,8 @@ FindGlyph (GlyphSetPtr glyphSet, Glyph id)
return glyph;
}
+#define GLYPH_SIZE (sizeof (GlyphRec) + dixPrivatesSize(PRIVATE_GLYPH))
+
GlyphPtr
AllocateGlyph (xGlyphInfo *gi, int fdepth)
{
@@ -381,13 +379,13 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth)
int i;
size = screenInfo.numScreens * sizeof (PicturePtr);
- glyph = (GlyphPtr) malloc(size + sizeof (GlyphRec));
+ glyph = (GlyphPtr) malloc (size + GLYPH_SIZE);
if (!glyph)
return 0;
glyph->refcnt = 0;
glyph->size = size + sizeof (xGlyphInfo);
glyph->info = *gi;
- glyph->devPrivates = NULL;
+ dixInitPrivates(glyph, glyph + 1, PRIVATE_GLYPH);
for (i = 0; i < screenInfo.numScreens; i++)
{
@@ -411,8 +409,7 @@ bail:
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
}
- FreeGlyphPrivates(glyph);
- free(glyph);
+ dixFreeObjectWithPrivates(glyph, PRIVATE_GLYPH);
return 0;
}
@@ -481,7 +478,6 @@ GlyphSetPtr
AllocateGlyphSet (int fdepth, PictFormatPtr format)
{
GlyphSetPtr glyphSet;
- int size;
if (!globalGlyphs[fdepth].hashSet)
{
@@ -489,8 +485,7 @@ AllocateGlyphSet (int fdepth, PictFormatPtr format)
return FALSE;
}
- size = sizeof (GlyphSetRec);
- glyphSet = calloc(1, size);
+ glyphSet = dixAllocateObjectWithPrivates(GlyphSetRec, PRIVATE_GLYPHSET);
if (!glyphSet)
return FALSE;
@@ -532,8 +527,7 @@ FreeGlyphSet (pointer value,
else
ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE);
free(table);
- dixFreePrivates(glyphSet->devPrivates);
- free(glyphSet);
+ dixFreeObjectWithPrivates(glyphSet, PRIVATE_GLYPHSET);
}
return Success;
}
diff --git a/render/picture.c b/render/picture.c
index ca5e18e74..f6e3a9e08 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -42,10 +42,8 @@
#include "picturestr.h"
#include "xace.h"
-static int PictureScreenPrivateKeyIndex;
-DevPrivateKey PictureScreenPrivateKey = &PictureScreenPrivateKeyIndex;
-static int PictureWindowPrivateKeyIndex;
-DevPrivateKey PictureWindowPrivateKey = &PictureWindowPrivateKeyIndex;
+DevPrivateKeyRec PictureScreenPrivateKeyRec;
+DevPrivateKeyRec PictureWindowPrivateKeyRec;
static int PictureGeneration;
RESTYPE PictureType;
RESTYPE PictFormatType;
@@ -628,6 +626,12 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
return FALSE;
PictureGeneration = serverGeneration;
}
+ if (!dixRegisterPrivateKey(&PictureScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&PictureWindowPrivateKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
if (!formats)
{
formats = PictureCreateDefaultFormats (pScreen, &nformats);
@@ -753,7 +757,7 @@ CreatePicture (Picture pid,
PicturePtr pPicture;
PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen);
- pPicture = (PicturePtr)malloc(sizeof(PictureRec));
+ pPicture = dixAllocateObjectWithPrivates(PictureRec, PRIVATE_PICTURE);
if (!pPicture)
{
*error = BadAlloc;
@@ -764,7 +768,6 @@ CreatePicture (Picture pid,
pPicture->pDrawable = pDrawable;
pPicture->pFormat = pFormat;
pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24);
- pPicture->devPrivates = NULL;
/* security creation/labeling check */
*error = XaceHook(XACE_RESOURCE_ACCESS, client, pid, PictureType, pPicture,
@@ -896,12 +899,11 @@ static void initGradient(SourcePictPtr pGradient, int stopCount,
static PicturePtr createSourcePicture(void)
{
PicturePtr pPicture;
- pPicture = (PicturePtr) malloc(sizeof(PictureRec));
+ pPicture = dixAllocateObjectWithPrivates(PictureRec, PRIVATE_PICTURE);
pPicture->pDrawable = 0;
pPicture->pFormat = 0;
pPicture->pNext = 0;
pPicture->format = PICT_a8r8g8b8;
- pPicture->devPrivates = 0;
SetPictureToDefaults(pPicture);
return pPicture;
@@ -1566,8 +1568,7 @@ FreePicture (pointer value,
(*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable);
}
}
- dixFreePrivates(pPicture->devPrivates);
- free(pPicture);
+ dixFreeObjectWithPrivates(pPicture, PRIVATE_PICTURE);
}
return Success;
}
diff --git a/render/picture.h b/render/picture.h
index 8bd38b98e..e5f0d78f6 100644
--- a/render/picture.h
+++ b/render/picture.h
@@ -174,7 +174,6 @@ extern _X_EXPORT int PictureCmapPolicy;
extern _X_EXPORT int PictureParseCmapPolicy (const char *name);
extern _X_EXPORT int RenderErrBase;
-extern _X_EXPORT DevPrivateKey RenderClientPrivateKey;
/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
diff --git a/render/picturestr.h b/render/picturestr.h
index a4011082b..da69ff601 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -396,8 +396,12 @@ typedef struct _PictureScreen {
} PictureScreenRec, *PictureScreenPtr;
-extern _X_EXPORT DevPrivateKey PictureScreenPrivateKey;
-extern _X_EXPORT DevPrivateKey PictureWindowPrivateKey;
+extern _X_EXPORT DevPrivateKeyRec PictureScreenPrivateKeyRec;
+#define PictureScreenPrivateKey (&PictureScreenPrivateKeyRec)
+
+extern _X_EXPORT DevPrivateKeyRec PictureWindowPrivateKeyRec;
+#define PictureWindowPrivateKey (&PictureWindowPrivateKeyRec)
+
extern _X_EXPORT RESTYPE PictureType;
extern _X_EXPORT RESTYPE PictFormatType;
extern _X_EXPORT RESTYPE GlyphSetType;
diff --git a/render/render.c b/render/render.c
index 78ecf43b7..40401a4f5 100644
--- a/render/render.c
+++ b/render/render.c
@@ -210,8 +210,8 @@ int (*SProcRenderVector[RenderNumberRequests])(ClientPtr) = {
};
int RenderErrBase;
-static int RenderClientPrivateKeyIndex;
-DevPrivateKey RenderClientPrivateKey = &RenderClientPrivateKeyIndex;
+static DevPrivateKeyRec RenderClientPrivateKeyRec;
+#define RenderClientPrivateKey (&RenderClientPrivateKeyRec )
typedef struct _RenderClient {
int major_version;
@@ -246,7 +246,7 @@ RenderExtensionInit (void)
return;
if (!PictureFinishInit ())
return;
- if (!dixRequestPrivate(RenderClientPrivateKey, sizeof(RenderClientRec)))
+ if (!dixRegisterPrivateKey(&RenderClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(RenderClientRec)))
return;
if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0))
return;