summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2008-01-03 17:04:54 +1030
committerPeter Hutterer <peter@cs.unisa.edu.au>2008-01-03 17:04:54 +1030
commit8da83836b60f7cdb75d08482f4311fa0e2ab4e1d (patch)
tree092efcfc39e3e293baaf04c4c84027ee453d3e13 /render
parenteace88989c3b65d5c20e9f37ea9b23c7c8e19335 (diff)
parentae869fc7669764729e13fdd70149ed636753f2a3 (diff)
Merge branch 'master' into mpx
Conflicts: XTrap/xtrapddmi.c Xext/security.c Xext/xprint.c Xext/xtest.c Xext/xvdisp.c Xi/exevents.c Xi/grabdevb.c Xi/grabdevk.c Xi/opendev.c Xi/ungrdev.c Xi/ungrdevb.c Xi/ungrdevk.c dix/cursor.c dix/devices.c dix/dixutils.c dix/events.c dix/getevents.c dix/main.c dix/window.c hw/xfree86/ramdac/xf86Cursor.c include/dix.h include/input.h include/inputstr.h mi/midispcur.c mi/miinitext.c mi/misprite.c render/animcur.c xfixes/cursor.c xkb/xkbAccessX.c
Diffstat (limited to 'render')
-rw-r--r--render/animcur.c32
-rw-r--r--render/glyph.c323
-rw-r--r--render/glyphstr.h43
-rw-r--r--render/mirect.c2
-rw-r--r--render/picture.c149
-rw-r--r--render/picture.h4
-rw-r--r--render/picturestr.h50
-rw-r--r--render/render.c250
8 files changed, 162 insertions, 691 deletions
diff --git a/render/animcur.c b/render/animcur.c
index 1172877dc..a87718d12 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -45,6 +45,7 @@
#include "opaque.h"
#include "picturestr.h"
#include "inputstr.h"
+#include "xace.h"
typedef struct _AnimCurElt {
CursorPtr pCursor; /* cursor to show */
@@ -89,14 +90,14 @@ static CursorBits animCursorBits = {
empty, empty, 2, 1, 1, 0, 0, 1
};
-static int AnimCurScreenPrivateIndex = -1;
static int AnimCurGeneration;
+static DevPrivateKey AnimCurScreenPrivateKey = &AnimCurScreenPrivateKey;
#define IsAnimCur(c) ((c)->bits == &animCursorBits)
#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
-#define GetAnimCurScreen(s) ((AnimCurScreenPtr) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr))
-#define GetAnimCurScreenIfSet(s) ((AnimCurScreenPrivateIndex != -1) ? GetAnimCurScreen(s) : NULL)
-#define SetAnimCurScreen(s,p) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr = (pointer) (p))
+#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey))
+#define GetAnimCurScreenIfSet(s) GetAnimCurScreen(s)
+#define SetAnimCurScreen(s,p) dixSetPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey, p)
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
@@ -132,8 +133,6 @@ AnimCurCloseScreen (int index, ScreenPtr pScreen)
SetAnimCurScreen(pScreen,0);
ret = (*pScreen->CloseScreen) (index, pScreen);
xfree (as);
- if (index == 0)
- AnimCurScreenPrivateIndex = -1;
return ret;
}
@@ -352,9 +351,6 @@ AnimCurInit (ScreenPtr pScreen)
if (AnimCurGeneration != serverGeneration)
{
int i;
- AnimCurScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (AnimCurScreenPrivateIndex < 0)
- return FALSE;
AnimCurGeneration = serverGeneration;
for (i = 0; i < MAX_DEVICES; i++) {
animCurState[i].pCursor = 0;
@@ -381,10 +377,10 @@ AnimCurInit (ScreenPtr pScreen)
}
int
-AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor)
+AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor, ClientPtr client, XID cid)
{
CursorPtr pCursor;
- int i;
+ int rc, i;
AnimCurPtr ac;
for (i = 0; i < screenInfo.numScreens; i++)
@@ -401,7 +397,6 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
if (!pCursor)
return BadAlloc;
pCursor->bits = &animCursorBits;
- animCursorBits.refcnt++;
pCursor->refcnt = 1;
pCursor->foreRed = cursors[0]->foreRed;
@@ -412,9 +407,22 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
pCursor->backGreen = cursors[0]->backGreen;
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);
+ xfree(pCursor);
+ return rc;
+ }
+
/*
* Fill in the AnimCurRec
*/
+ animCursorBits.refcnt++;
ac = GetAnimCur (pCursor);
ac->nelt = ncursor;
ac->elts = (AnimCurElt *) (ac + 1);
diff --git a/render/glyph.c b/render/glyph.c
index e1dc0bc99..286e39d63 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -85,220 +85,19 @@ static const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
static GlyphHashRec globalGlyphs[GlyphFormatNum];
-static int globalTotalGlyphPrivateSize = 0;
-
-static int glyphPrivateCount = 0;
-
-void
-ResetGlyphPrivates (void)
-{
- glyphPrivateCount = 0;
-}
-
-int
-AllocateGlyphPrivateIndex (void)
-{
- 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)
+FreeGlyphPrivates (GlyphPtr glyph)
{
- PictureScreenPtr ps;
- int offset = 0;
- int i;
+ ScreenPtr pScreen;
+ 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);
- }
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pScreen = screenInfo.screens[i];
+ dixFreePrivates(*GetGlyphPrivatesForScreen(glyph, pScreen));
}
-}
-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;
+ dixFreePrivates(glyph->devPrivates);
+ glyph->devPrivates = NULL;
}
void
@@ -308,8 +107,6 @@ GlyphUninit (ScreenPtr pScreen)
GlyphPtr glyph;
int fdepth, i;
- globalTotalGlyphPrivateSize -= ps->totalGlyphPrivateSize;
-
for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
{
if (!globalGlyphs[fdepth].hashSet)
@@ -321,43 +118,19 @@ GlyphUninit (ScreenPtr pScreen)
if (glyph && glyph != DeletedGlyph)
{
(*ps->UnrealizeGlyph) (pScreen, glyph);
-
- if (globalTotalGlyphPrivateSize)
- {
- if (!ReallocGlobalGlyphPrivate (glyph))
- return;
- }
- else
- {
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
- glyph->devPrivates = NULL;
- }
+ FreeGlyphPrivates(glyph);
}
}
}
- 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
@@ -371,50 +144,6 @@ 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;
-}
-
GlyphRefPtr
FindGlyphRef (GlyphHashPtr hash,
CARD32 signature,
@@ -582,8 +311,7 @@ FreeGlyph (GlyphPtr glyph, int format)
(*ps->UnrealizeGlyph) (pScreen, glyph);
}
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
+ FreeGlyphPrivates(glyph);
xfree (glyph);
}
}
@@ -610,8 +338,7 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
if (ps)
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
}
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
+ FreeGlyphPrivates(glyph);
xfree (glyph);
glyph = gr->glyph;
}
@@ -678,16 +405,7 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth)
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;
+ glyph->devPrivates = NULL;
for (i = 0; i < screenInfo.numScreens; i++)
{
@@ -709,9 +427,8 @@ bail:
if (ps)
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
}
-
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
+
+ FreeGlyphPrivates(glyph);
xfree (glyph);
return 0;
}
@@ -790,15 +507,11 @@ AllocateGlyphSet (int fdepth, PictFormatPtr format)
return FALSE;
}
- size = (sizeof (GlyphSetRec) +
- (sizeof (pointer) * _GlyphSetPrivateAllocateIndex));
+ size = sizeof (GlyphSetRec);
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]))
{
@@ -838,11 +551,7 @@ FreeGlyphSet (pointer value,
else
ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE);
xfree (table);
-
- if (glyphSet->devPrivates &&
- glyphSet->devPrivates != (pointer)(&glyphSet[1]))
- xfree(glyphSet->devPrivates);
-
+ dixFreePrivates(glyphSet->devPrivates);
xfree (glyphSet);
}
return Success;
diff --git a/render/glyphstr.h b/render/glyphstr.h
index c6ab5aa11..67b21fe63 100644
--- a/render/glyphstr.h
+++ b/render/glyphstr.h
@@ -30,6 +30,7 @@
#include "screenint.h"
#include "regionstr.h"
#include "miscstruct.h"
+#include "privates.h"
#define GlyphFormat1 0
#define GlyphFormat4 1
@@ -40,7 +41,7 @@
typedef struct _Glyph {
CARD32 refcnt;
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
unsigned char sha1[20];
CARD32 size; /* info + bitmap */
xGlyphInfo info;
@@ -74,18 +75,14 @@ typedef struct _GlyphSet {
int fdepth;
GlyphHashRec hash;
int maxPrivate;
- pointer *devPrivates;
+ PrivateRec *devPrivates;
} GlyphSetRec, *GlyphSetPtr;
-#define GlyphSetGetPrivate(pGlyphSet,n) \
- ((n) > (pGlyphSet)->maxPrivate ? \
- (pointer) 0 : \
- (pGlyphSet)->devPrivates[n])
+#define GlyphSetGetPrivate(pGlyphSet,k) \
+ dixLookupPrivate(&(pGlyphSet)->devPrivates, k)
-#define GlyphSetSetPrivate(pGlyphSet,n,ptr) \
- ((n) > (pGlyphSet)->maxPrivate ? \
- _GlyphSetSetNewPrivate(pGlyphSet, n, ptr) : \
- ((((pGlyphSet)->devPrivates[n] = (ptr)) != 0) || TRUE))
+#define GlyphSetSetPrivate(pGlyphSet,k,ptr) \
+ dixSetPrivate(&(pGlyphSet)->devPrivates, k, ptr)
typedef struct _GlyphList {
INT16 xOff;
@@ -97,32 +94,6 @@ typedef struct _GlyphList {
GlyphHashSetPtr
FindGlyphHashSet (CARD32 filled);
-int
-AllocateGlyphSetPrivateIndex (void);
-
-void
-ResetGlyphSetPrivateIndex (void);
-
-Bool
-_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr);
-
-void
-ResetGlyphPrivates (void);
-
-int
-AllocateGlyphPrivateIndex (void);
-
-Bool
-AllocateGlyphPrivate (ScreenPtr pScreen,
- int index2,
- unsigned amount);
-
-Bool
-GlyphInit (ScreenPtr pScreen);
-
-Bool
-GlyphFinishInit (ScreenPtr pScreen);
-
void
GlyphUninit (ScreenPtr pScreen);
diff --git a/render/mirect.c b/render/mirect.c
index 464df51c1..38f4faf67 100644
--- a/render/mirect.c
+++ b/render/mirect.c
@@ -158,7 +158,7 @@ miCompositeRects (CARD8 op,
tmpval[0] = xTrue;
pSrc = CreatePicture (0, &pPixmap->drawable, rgbaFormat,
- CPRepeat, tmpval, 0, &error);
+ CPRepeat, tmpval, serverClient, &error);
if (!pSrc)
goto bail4;
diff --git a/render/picture.c b/render/picture.c
index a7e40f994..35e2a28b3 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -40,66 +40,17 @@
#include "gcstruct.h"
#include "servermd.h"
#include "picturestr.h"
+#include "xace.h"
+#include "registry.h"
-_X_EXPORT int PictureScreenPrivateIndex = -1;
-int PictureWindowPrivateIndex;
+_X_EXPORT DevPrivateKey PictureScreenPrivateKey = &PictureScreenPrivateKey;
+DevPrivateKey PictureWindowPrivateKey = &PictureWindowPrivateKey;
static int PictureGeneration;
RESTYPE PictureType;
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)
{
@@ -137,8 +88,6 @@ PictureCloseScreen (int index, ScreenPtr pScreen)
(*ps->CloseIndexed) (pScreen, &ps->formats[n]);
GlyphUninit (pScreen);
SetPictureScreen(pScreen, 0);
- if (ps->PicturePrivateSizes)
- xfree (ps->PicturePrivateSizes);
xfree (ps->formats);
xfree (ps);
return ret;
@@ -497,8 +446,6 @@ PictureFinishInit (void)
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]);
@@ -637,20 +584,11 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
GlyphSetType = CreateNewResourceType (FreeGlyphSet);
if (!GlyphSetType)
return FALSE;
- PictureScreenPrivateIndex = AllocateScreenPrivateIndex();
- if (PictureScreenPrivateIndex < 0)
- return FALSE;
- PictureWindowPrivateIndex = AllocateWindowPrivateIndex();
PictureGeneration = serverGeneration;
-#ifdef XResExtension
RegisterResourceName (PictureType, "PICTURE");
RegisterResourceName (PictFormatType, "PICTFORMAT");
RegisterResourceName (GlyphSetType, "GLYPHSET");
-#endif
}
- if (!AllocateWindowPrivate (pScreen, PictureWindowPrivateIndex, 0))
- return FALSE;
-
if (!formats)
{
formats = PictureCreateDefaultFormats (pScreen, &nformats);
@@ -697,18 +635,7 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
return FALSE;
}
SetPictureScreen(pScreen, ps);
- if (!GlyphInit (pScreen))
- {
- SetPictureScreen(pScreen, 0);
- xfree (formats);
- xfree (ps);
- return FALSE;
- }
- ps->totalPictureSize = sizeof (PictureRec);
- ps->PicturePrivateSizes = 0;
- ps->PicturePrivateLen = 0;
-
ps->formats = formats;
ps->fallback = formats;
ps->nformats = nformats;
@@ -774,37 +701,6 @@ SetPictureToDefaults (PicturePtr pPicture)
}
PicturePtr
-AllocatePicture (ScreenPtr pScreen)
-{
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- PicturePtr pPicture;
- char *ptr;
- DevUnion *ppriv;
- unsigned int *sizes;
- unsigned int size;
- int i;
-
- pPicture = (PicturePtr) xalloc (ps->totalPictureSize);
- if (!pPicture)
- return 0;
- ppriv = (DevUnion *)(pPicture + 1);
- pPicture->devPrivates = ppriv;
- sizes = ps->PicturePrivateSizes;
- ptr = (char *)(ppriv + ps->PicturePrivateLen);
- for (i = ps->PicturePrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
- return pPicture;
-}
-
-PicturePtr
CreatePicture (Picture pid,
DrawablePtr pDrawable,
PictFormatPtr pFormat,
@@ -816,7 +712,7 @@ CreatePicture (Picture pid,
PicturePtr pPicture;
PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen);
- pPicture = AllocatePicture (pDrawable->pScreen);
+ pPicture = (PicturePtr)xalloc(sizeof(PictureRec));
if (!pPicture)
{
*error = BadAlloc;
@@ -827,6 +723,14 @@ 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,
+ RT_PIXMAP, pDrawable, DixCreateAccess|DixSetAttrAccess);
+ if (*error != Success)
+ goto out;
+
if (pDrawable->type == DRAWABLE_PIXMAP)
{
++((PixmapPtr)pDrawable)->refcnt;
@@ -846,6 +750,7 @@ CreatePicture (Picture pid,
*error = Success;
if (*error == Success)
*error = (*ps->CreatePicture) (pPicture);
+out:
if (*error != Success)
{
FreePicture (pPicture, (XID) 0);
@@ -1163,14 +1068,13 @@ ChangePicture (PicturePtr pPicture,
pAlpha = 0;
else
{
- pAlpha = (PicturePtr) SecurityLookupIDByType(client,
- pid,
- PictureType,
- DixWriteAccess|DixReadAccess);
- if (!pAlpha)
+ error = dixLookupResource((pointer *)&pAlpha, pid,
+ PictureType, client,
+ DixReadAccess);
+ if (error != Success)
{
client->errorValue = pid;
- error = BadPixmap;
+ error = (error == BadValue) ? BadPixmap : error;
break;
}
if (pAlpha->pDrawable == NULL ||
@@ -1225,14 +1129,13 @@ ChangePicture (PicturePtr pPicture,
else
{
clipType = CT_PIXMAP;
- pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
- pid,
- RT_PIXMAP,
- DixReadAccess);
- if (!pPixmap)
+ error = dixLookupResource((pointer *)&pPixmap, pid,
+ RT_PIXMAP, client,
+ DixReadAccess);
+ if (error != Success)
{
client->errorValue = pid;
- error = BadPixmap;
+ error = (error == BadValue) ? BadPixmap : error;
break;
}
}
@@ -1607,7 +1510,8 @@ FreePicture (pointer value,
WindowPtr pWindow = (WindowPtr) pPicture->pDrawable;
PicturePtr *pPrev;
- for (pPrev = (PicturePtr *) &((pWindow)->devPrivates[PictureWindowPrivateIndex].ptr);
+ for (pPrev = (PicturePtr *)dixLookupPrivateAddr
+ (&pWindow->devPrivates, PictureWindowPrivateKey);
*pPrev;
pPrev = &(*pPrev)->pNext)
{
@@ -1623,6 +1527,7 @@ FreePicture (pointer value,
(*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable);
}
}
+ dixFreePrivates(pPicture->devPrivates);
xfree (pPicture);
}
return Success;
diff --git a/render/picture.h b/render/picture.h
index e8a098cd9..045b29944 100644
--- a/render/picture.h
+++ b/render/picture.h
@@ -163,8 +163,8 @@ extern int PictureCmapPolicy;
int PictureParseCmapPolicy (const char *name);
-extern int RenderErrBase;
-extern int RenderClientPrivateIndex;
+extern int RenderErrBase;
+extern DevPrivateKey RenderClientPrivateKey;
/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
diff --git a/render/picturestr.h b/render/picturestr.h
index b2e180f11..acd15c7fe 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -27,6 +27,7 @@
#include "scrnintstr.h"
#include "glyphstr.h"
#include "resource.h"
+#include "privates.h"
typedef struct _DirectFormat {
CARD16 red, redMask;
@@ -173,7 +174,7 @@ typedef struct _Picture {
RegionPtr pCompositeClip;
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
PictTransform *transform;
@@ -328,10 +329,6 @@ typedef void (*UnrealizeGlyphProcPtr) (ScreenPtr pScreen,
GlyphPtr glyph);
typedef struct _PictureScreen {
- int totalPictureSize;
- unsigned int *PicturePrivateSizes;
- int PicturePrivateLen;
-
PictFormatPtr formats;
PictFormatPtr fallback;
int nformats;
@@ -389,30 +386,25 @@ typedef struct _PictureScreen {
AddTrapsProcPtr AddTraps;
- int totalGlyphPrivateSize;
- unsigned int *glyphPrivateSizes;
- int glyphPrivateLen;
- int glyphPrivateOffset;
-
RealizeGlyphProcPtr RealizeGlyph;
UnrealizeGlyphProcPtr UnrealizeGlyph;
} PictureScreenRec, *PictureScreenPtr;
-extern int PictureScreenPrivateIndex;
-extern int PictureWindowPrivateIndex;
+extern DevPrivateKey PictureScreenPrivateKey;
+extern DevPrivateKey PictureWindowPrivateKey;
extern RESTYPE PictureType;
extern RESTYPE PictFormatType;
extern RESTYPE GlyphSetType;
-#define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr))
-#define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL)
-#define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (pointer) (p))
-#define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr))
-#define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (pointer) (p))
+#define GetPictureScreen(s) ((PictureScreenPtr)dixLookupPrivate(&(s)->devPrivates, PictureScreenPrivateKey))
+#define GetPictureScreenIfSet(s) GetPictureScreen(s)
+#define SetPictureScreen(s,p) dixSetPrivate(&(s)->devPrivates, PictureScreenPrivateKey, p)
+#define GetPictureWindow(w) ((PicturePtr)dixLookupPrivate(&(w)->devPrivates, PictureWindowPrivateKey))
+#define SetPictureWindow(w,p) dixSetPrivate(&(w)->devPrivates, PictureWindowPrivateKey, p)
-#define GetGlyphPrivatesForScreen(glyph, s) \
- ((glyph)->devPrivates + (GetPictureScreen (s))->glyphPrivateOffset)
+#define GetGlyphPrivatesForScreen(glyph, s) \
+ ((PrivateRec **)dixLookupPrivateAddr(&(glyph)->devPrivates, s))
#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\
pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\
@@ -430,15 +422,6 @@ extern RESTYPE GlyphSetType;
} \
} \
-void
-ResetPicturePrivateIndex (void);
-
-int
-AllocatePicturePrivateIndex (void);
-
-Bool
-AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount);
-
Bool
PictureDestroyWindow (WindowPtr pWindow);
@@ -502,15 +485,6 @@ void
SetPictureToDefaults (PicturePtr pPicture);
PicturePtr
-AllocatePicture (ScreenPtr pScreen);
-
-#if 0
-Bool
-miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
-#endif
-
-
-PicturePtr
CreatePicture (Picture pid,
DrawablePtr pDrawable,
PictFormatPtr pFormat,
@@ -650,7 +624,7 @@ Bool
AnimCurInit (ScreenPtr pScreen);
int
-AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor);
+AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor, ClientPtr client, XID cid);
void
AddTraps (PicturePtr pPicture,
diff --git a/render/render.c b/render/render.c
index 3a9d24a02..f03f54a2b 100644
--- a/render/render.c
+++ b/render/render.c
@@ -46,6 +46,7 @@
#include "glyphstr.h"
#include <X11/Xfuncproto.h>
#include "cursorstr.h"
+#include "xace.h"
#if HAVE_STDINT_H
#include <stdint.h>
@@ -212,18 +213,15 @@ int (*SProcRenderVector[RenderNumberRequests])(ClientPtr) = {
static void
RenderResetProc (ExtensionEntry *extEntry);
-#if 0
-static CARD8 RenderReqCode;
-#endif
int RenderErrBase;
-int RenderClientPrivateIndex;
+DevPrivateKey RenderClientPrivateKey;
typedef struct _RenderClient {
int major_version;
int minor_version;
} RenderClientRec, *RenderClientPtr;
-#define GetRenderClient(pClient) ((RenderClientPtr) (pClient)->devPrivates[RenderClientPrivateIndex].ptr)
+#define GetRenderClient(pClient) ((RenderClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RenderClientPrivateKey))
static void
RenderClientCallback (CallbackListPtr *list,
@@ -247,9 +245,7 @@ RenderExtensionInit (void)
return;
if (!PictureFinishInit ())
return;
- RenderClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (RenderClientPrivateIndex,
- sizeof (RenderClientRec)))
+ if (!dixRequestPrivate(RenderClientPrivateKey, sizeof(RenderClientRec)))
return;
if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0))
return;
@@ -259,17 +255,12 @@ RenderExtensionInit (void)
RenderResetProc, StandardMinorOpcode);
if (!extEntry)
return;
-#if 0
- RenderReqCode = (CARD8) extEntry->base;
-#endif
RenderErrBase = extEntry->errorBase;
}
static void
RenderResetProc (ExtensionEntry *extEntry)
{
- ResetPicturePrivateIndex();
- ResetGlyphSetPrivateIndex();
}
static int
@@ -299,26 +290,6 @@ ProcRenderQueryVersion (ClientPtr client)
return (client->noClientException);
}
-#if 0
-static int
-VisualDepth (ScreenPtr pScreen, VisualPtr pVisual)
-{
- DepthPtr pDepth;
- int d, v;
-
- for (d = 0; d < pScreen->numDepths; d++)
- {
- pDepth = pScreen->allowedDepths + d;
- for (v = 0; v < pDepth->numVids; v++)
- {
- if (pDepth->vids[v] == pVisual->vid)
- return pDepth->depth;
- }
- }
- return 0;
-}
-#endif
-
static VisualPtr
findVisual (ScreenPtr pScreen, VisualID vid)
{
@@ -627,7 +598,7 @@ ProcRenderCreatePicture (ClientPtr client)
LEGAL_NEW_RESOURCE(stuff->pid, client);
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixWriteAccess);
+ DixReadAccess|DixAddAccess);
if (rc != Success)
return rc;
@@ -668,7 +639,7 @@ ProcRenderChangePicture (ClientPtr client)
int len;
REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
- VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess,
+ VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess,
RenderErrBase + BadPicture);
len = client->req_len - (sizeof(xRenderChangePictureReq) >> 2);
@@ -688,7 +659,7 @@ ProcRenderSetPictureClipRectangles (ClientPtr client)
int result;
REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
- VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess,
+ VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess,
RenderErrBase + BadPicture);
if (!pPicture->pDrawable)
return BadDrawable;
@@ -987,7 +958,7 @@ ProcRenderCreateGlyphSet (ClientPtr client)
{
GlyphSetPtr glyphSet;
PictFormatPtr format;
- int f;
+ int rc, f;
REQUEST(xRenderCreateGlyphSetReq);
REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
@@ -1026,6 +997,11 @@ ProcRenderCreateGlyphSet (ClientPtr client)
glyphSet = AllocateGlyphSet (f, format);
if (!glyphSet)
return BadAlloc;
+ /* security creation/labeling check */
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->gsid, GlyphSetType,
+ glyphSet, RT_NONE, NULL, DixCreateAccess);
+ if (rc != Success)
+ return rc;
if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet))
return BadAlloc;
return Success;
@@ -1035,20 +1011,19 @@ static int
ProcRenderReferenceGlyphSet (ClientPtr client)
{
GlyphSetPtr glyphSet;
+ int rc;
REQUEST(xRenderReferenceGlyphSetReq);
REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq);
LEGAL_NEW_RESOURCE(stuff->gsid, client);
- glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
- stuff->existing,
- GlyphSetType,
- DixWriteAccess);
- if (!glyphSet)
+ rc = dixLookupResource((pointer *)&glyphSet, stuff->existing, GlyphSetType,
+ client, DixGetAttrAccess);
+ if (rc != Success)
{
client->errorValue = stuff->existing;
- return RenderErrBase + BadGlyphSet;
+ return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
}
glyphSet->refcnt++;
if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet))
@@ -1063,17 +1038,16 @@ static int
ProcRenderFreeGlyphSet (ClientPtr client)
{
GlyphSetPtr glyphSet;
+ int rc;
REQUEST(xRenderFreeGlyphSetReq);
REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
- glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
- stuff->glyphset,
- GlyphSetType,
- DixDestroyAccess);
- if (!glyphSet)
+ rc = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
+ client, DixDestroyAccess);
+ if (rc != Success)
{
client->errorValue = stuff->glyphset;
- return RenderErrBase + BadGlyphSet;
+ return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
}
FreeResource (stuff->glyphset, RT_NONE);
return client->noClientException;
@@ -1100,23 +1074,22 @@ ProcRenderAddGlyphs (ClientPtr client)
xGlyphInfo *gi;
CARD8 *bits;
int size;
- int err = BadAlloc;
+ int err;
int i, screen;
PicturePtr pSrc = NULL, pDst = NULL;
PixmapPtr pSrcPix = NULL, pDstPix = NULL;
CARD32 component_alpha;
REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
- glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
- stuff->glyphset,
- GlyphSetType,
- DixWriteAccess);
- if (!glyphSet)
+ err = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
+ client, DixAddAccess);
+ if (err != Success)
{
client->errorValue = stuff->glyphset;
- return RenderErrBase + BadGlyphSet;
+ return (err == BadValue) ? RenderErrBase + BadGlyphSet : err;
}
+ err = BadAlloc;
nglyphs = stuff->nglyphs;
if (nglyphs > UINT32_MAX / sizeof(GlyphNewRec))
return BadAlloc;
@@ -1203,7 +1176,7 @@ ProcRenderAddGlyphs (ClientPtr client)
pDstPix = (pScreen->CreatePixmap) (pScreen,
width, height, depth,
- CREATE_PIMXAP_USAGE_GLYPH_PICTURE);
+ CREATE_PIXMAP_USAGE_GLYPH_PICTURE);
GlyphPicture (glyph)[screen] = pDst =
CreatePicture (0, &pDstPix->drawable,
@@ -1286,19 +1259,17 @@ ProcRenderFreeGlyphs (ClientPtr client)
{
REQUEST(xRenderFreeGlyphsReq);
GlyphSetPtr glyphSet;
- int nglyph;
+ int rc, nglyph;
CARD32 *gids;
CARD32 glyph;
REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
- glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
- stuff->glyphset,
- GlyphSetType,
- DixWriteAccess);
- if (!glyphSet)
+ rc = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
+ client, DixRemoveAccess);
+ if (rc != Success)
{
client->errorValue = stuff->glyphset;
- return RenderErrBase + BadGlyphSet;
+ return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
}
nglyph = ((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq)) >> 2;
gids = (CARD32 *) (stuff + 1);
@@ -1375,7 +1346,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
stuff->glyphset,
GlyphSetType,
- DixReadAccess);
+ DixUseAccess);
if (!glyphSet)
{
client->errorValue = stuff->glyphset;
@@ -1437,7 +1408,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
gs,
GlyphSetType,
- DixReadAccess);
+ DixUseAccess);
if (!glyphSet)
{
client->errorValue = gs;
@@ -1579,7 +1550,7 @@ ProcRenderCreateCursor (ClientPtr client)
CursorMetricRec cm;
CursorPtr pCursor;
CARD32 twocolor[3];
- int ncolor;
+ int rc, ncolor;
REQUEST_SIZE_MATCH (xRenderCreateCursorReq);
LEGAL_NEW_RESOURCE(stuff->cid, client);
@@ -1747,16 +1718,20 @@ ProcRenderCreateCursor (ClientPtr client)
cm.height = height;
cm.xhot = stuff->x;
cm.yhot = stuff->y;
- pCursor = AllocCursorARGB (srcbits, mskbits, argbbits, &cm,
- GetColor(twocolor[0], 16),
- GetColor(twocolor[0], 8),
- GetColor(twocolor[0], 0),
- GetColor(twocolor[1], 16),
- GetColor(twocolor[1], 8),
- GetColor(twocolor[1], 0));
- if (pCursor && AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
- return (client->noClientException);
- return BadAlloc;
+ rc = AllocARGBCursor(srcbits, mskbits, argbbits, &cm,
+ GetColor(twocolor[0], 16),
+ GetColor(twocolor[0], 8),
+ GetColor(twocolor[0], 0),
+ GetColor(twocolor[1], 16),
+ GetColor(twocolor[1], 8),
+ GetColor(twocolor[1], 0),
+ &pCursor, client, stuff->cid);
+ if (rc != Success)
+ return rc;
+ if (!AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
+ return BadAlloc;
+
+ return client->noClientException;
}
static int
@@ -1767,7 +1742,7 @@ ProcRenderSetPictureTransform (ClientPtr client)
int result;
REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
- VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess,
+ VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess,
RenderErrBase + BadPicture);
result = SetPictureTransform (pPicture, (PictTransform *) &stuff->transform);
if (client->noClientException != Success)
@@ -1792,7 +1767,7 @@ ProcRenderQueryFilters (ClientPtr client)
REQUEST_SIZE_MATCH(xRenderQueryFiltersReq);
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
+ DixGetAttrAccess);
if (rc != Success)
return rc;
@@ -1897,7 +1872,7 @@ ProcRenderSetPictureFilter (ClientPtr client)
char *name;
REQUEST_AT_LEAST_SIZE (xRenderSetPictureFilterReq);
- VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess,
+ VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess,
RenderErrBase + BadPicture);
name = (char *) (stuff + 1);
params = (xFixed *) (name + ((stuff->nbytes + 3) & ~3));
@@ -1941,7 +1916,8 @@ ProcRenderCreateAnimCursor (ClientPtr client)
deltas[i] = elt->delay;
elt++;
}
- ret = AnimCursorCreate (cursors, deltas, ncursor, &pCursor);
+ ret = AnimCursorCreate (cursors, deltas, ncursor, &pCursor, client,
+ stuff->cid);
xfree (cursors);
if (ret != Success)
return ret;
@@ -1987,6 +1963,11 @@ static int ProcRenderCreateSolidFill(ClientPtr client)
pPicture = CreateSolidPicture(stuff->pid, &stuff->color, &error);
if (!pPicture)
return error;
+ /* security creation/labeling check */
+ error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
+ pPicture, RT_NONE, NULL, DixCreateAccess);
+ if (error != Success)
+ return error;
if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
return BadAlloc;
return Success;
@@ -2016,6 +1997,11 @@ static int ProcRenderCreateLinearGradient (ClientPtr client)
stuff->nStops, stops, colors, &error);
if (!pPicture)
return error;
+ /* security creation/labeling check */
+ error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
+ pPicture, RT_NONE, NULL, DixCreateAccess);
+ if (error != Success)
+ return error;
if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
return BadAlloc;
return Success;
@@ -2046,6 +2032,11 @@ static int ProcRenderCreateRadialGradient (ClientPtr client)
stuff->nStops, stops, colors, &error);
if (!pPicture)
return error;
+ /* security creation/labeling check */
+ error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
+ pPicture, RT_NONE, NULL, DixCreateAccess);
+ if (error != Success)
+ return error;
if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
return BadAlloc;
return Success;
@@ -2075,6 +2066,11 @@ static int ProcRenderCreateConicalGradient (ClientPtr client)
stuff->nStops, stops, colors, &error);
if (!pPicture)
return error;
+ /* security creation/labeling check */
+ error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
+ pPicture, RT_NONE, NULL, DixCreateAccess);
+ if (error != Success)
+ return error;
if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
return BadAlloc;
return Success;
@@ -3225,98 +3221,6 @@ PanoramiXRenderTriFan(ClientPtr client)
return result;
}
-#if 0 /* Not implemented yet */
-
-static int
-PanoramiXRenderColorTrapezoids(ClientPtr client)
-{
- PanoramiXRes *src, *dst;
- int result = Success, j;
- REQUEST(xRenderColorTrapezoidsReq);
- char *extra;
- int extra_len;
-
- REQUEST_AT_LEAST_SIZE (xRenderColorTrapezoidsReq);
-
- VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess,
- RenderErrBase + BadPicture);
-
- extra_len = (client->req_len << 2) - sizeof (xRenderColorTrapezoidsReq);
-
- if (extra_len &&
- (extra = (char *) xalloc (extra_len))) {
- memcpy (extra, stuff + 1, extra_len);
-
- FOR_NSCREENS_FORWARD(j) {
- if (j) memcpy (stuff + 1, extra, extra_len);
- if (dst->u.pict.root) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
-
- if(x_off || y_off) {
- ....;
- }
- }
-
- stuff->dst = dst->info[j].id;
- result =
- (*PanoramiXSaveRenderVector[X_RenderColorTrapezoids]) (client);
-
- if(result != Success) break;
- }
-
- xfree(extra);
- }
-
- return result;
-}
-
-static int
-PanoramiXRenderColorTriangles(ClientPtr client)
-{
- PanoramiXRes *src, *dst;
- int result = Success, j;
- REQUEST(xRenderColorTrianglesReq);
- char *extra;
- int extra_len;
-
- REQUEST_AT_LEAST_SIZE (xRenderColorTrianglesReq);
-
- VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess,
- RenderErrBase + BadPicture);
-
- extra_len = (client->req_len << 2) - sizeof (xRenderColorTrianglesReq);
-
- if (extra_len &&
- (extra = (char *) xalloc (extra_len))) {
- memcpy (extra, stuff + 1, extra_len);
-
- FOR_NSCREENS_FORWARD(j) {
- if (j) memcpy (stuff + 1, extra, extra_len);
- if (dst->u.pict.root) {
- int x_off = panoramiXdataPtr[j].x;
- int y_off = panoramiXdataPtr[j].y;
-
- if(x_off || y_off) {
- ....;
- }
- }
-
- stuff->dst = dst->info[j].id;
- result =
- (*PanoramiXSaveRenderVector[X_RenderColorTriangles]) (client);
-
- if(result != Success) break;
- }
-
- xfree(extra);
- }
-
- return result;
-}
-
-#endif
-
static int
PanoramiXRenderAddTraps (ClientPtr client)
{