aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/render/render.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-09-06 18:48:27 +0000
committermarha <marha@users.sourceforge.net>2009-09-06 18:48:27 +0000
commita915739887477b28d924ecc8417ee107d125bd6c (patch)
treec02f315476b61892d1fd89182e18943dce8d6277 /xorg-server/render/render.c
parent6f25a23db1df27e992c34f6fd4c82e83c44fc2e2 (diff)
downloadvcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.tar.gz
vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.tar.bz2
vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.zip
Switched to xorg-server-1.6.99.900.tar.gz
Diffstat (limited to 'xorg-server/render/render.c')
-rw-r--r--xorg-server/render/render.c203
1 files changed, 79 insertions, 124 deletions
diff --git a/xorg-server/render/render.c b/xorg-server/render/render.c
index e3d76d2c1..995ebd956 100644
--- a/xorg-server/render/render.c
+++ b/xorg-server/render/render.c
@@ -22,8 +22,6 @@
* Author: Keith Packard, SuSE, Inc.
*/
-#define NEED_REPLIES
-#define NEED_EVENTS
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -268,6 +266,7 @@ ProcRenderQueryVersion (ClientPtr client)
pRenderClient->minor_version = stuff->minorVersion;
REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
+ memset(&rep, 0, sizeof(xRenderQueryVersionReply));
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
@@ -365,12 +364,12 @@ ProcRenderQueryPictFormats (ClientPtr client)
ndepth * sizeof (xPictDepth) +
nvisual * sizeof (xPictVisual) +
numSubpixel * sizeof (CARD32));
- reply = (xRenderQueryPictFormatsReply *) xalloc (rlength);
+ reply = (xRenderQueryPictFormatsReply *) xcalloc (1, rlength);
if (!reply)
return BadAlloc;
reply->type = X_Reply;
reply->sequenceNumber = client->sequence;
- reply->length = (rlength - sizeof(xGenericReply)) >> 2;
+ reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
reply->numFormats = nformat;
reply->numScreens = numScreens;
reply->numDepths = ndepth;
@@ -510,7 +509,7 @@ static int
ProcRenderQueryPictIndexValues (ClientPtr client)
{
PictFormatPtr pFormat;
- int num;
+ int rc, num;
int rlength;
int i, n;
REQUEST(xRenderQueryPictIndexValuesReq);
@@ -519,16 +518,11 @@ ProcRenderQueryPictIndexValues (ClientPtr client)
REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq);
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->format,
- PictFormatType,
- DixReadAccess);
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->format,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
- if (!pFormat)
- {
- client->errorValue = stuff->format;
- return RenderErrBase + BadPictFormat;
- }
if (pFormat->type != PictTypeIndexed)
{
client->errorValue = stuff->format;
@@ -543,7 +537,7 @@ ProcRenderQueryPictIndexValues (ClientPtr client)
reply->type = X_Reply;
reply->sequenceNumber = client->sequence;
- reply->length = (rlength - sizeof(xGenericReply)) >> 2;
+ reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
reply->numIndexValues = num;
values = (xIndexValue *) (reply + 1);
@@ -593,18 +587,14 @@ ProcRenderCreatePicture (ClientPtr client)
if (rc != Success)
return rc;
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->format,
- PictFormatType,
- DixReadAccess);
- if (!pFormat)
- {
- client->errorValue = stuff->format;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->format,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
+
if (pFormat->depth != pDrawable->depth)
return BadMatch;
- len = client->req_len - (sizeof(xRenderCreatePictureReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xRenderCreatePictureReq));
if (Ones(stuff->mask) != len)
return BadLength;
@@ -633,7 +623,7 @@ ProcRenderChangePicture (ClientPtr client)
VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess,
RenderErrBase + BadPicture);
- len = client->req_len - (sizeof(xRenderChangePictureReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xRenderChangePictureReq));
if (Ones(stuff->mask) != len)
return BadLength;
@@ -691,6 +681,8 @@ PictOpValid (CARD8 op)
return TRUE;
if (PictOpConjointMinimum <= op && op <= PictOpConjointMaximum)
return TRUE;
+ if (PictOpBlendMinimum <= op && op <= PictOpBlendMaximum)
+ return TRUE;
return FALSE;
}
@@ -741,7 +733,7 @@ ProcRenderScale (ClientPtr client)
static int
ProcRenderTrapezoids (ClientPtr client)
{
- int ntraps;
+ int rc, ntraps;
PicturePtr pSrc, pDst;
PictFormatPtr pFormat;
REQUEST(xRenderTrapezoidsReq);
@@ -762,15 +754,10 @@ ProcRenderTrapezoids (ClientPtr client)
return BadMatch;
if (stuff->maskFormat)
{
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->maskFormat,
- PictFormatType,
- DixReadAccess);
- if (!pFormat)
- {
- client->errorValue = stuff->maskFormat;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
}
else
pFormat = 0;
@@ -788,7 +775,7 @@ ProcRenderTrapezoids (ClientPtr client)
static int
ProcRenderTriangles (ClientPtr client)
{
- int ntris;
+ int rc, ntris;
PicturePtr pSrc, pDst;
PictFormatPtr pFormat;
REQUEST(xRenderTrianglesReq);
@@ -809,15 +796,10 @@ ProcRenderTriangles (ClientPtr client)
return BadMatch;
if (stuff->maskFormat)
{
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->maskFormat,
- PictFormatType,
- DixReadAccess);
- if (!pFormat)
- {
- client->errorValue = stuff->maskFormat;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
}
else
pFormat = 0;
@@ -835,7 +817,7 @@ ProcRenderTriangles (ClientPtr client)
static int
ProcRenderTriStrip (ClientPtr client)
{
- int npoints;
+ int rc, npoints;
PicturePtr pSrc, pDst;
PictFormatPtr pFormat;
REQUEST(xRenderTrianglesReq);
@@ -856,15 +838,10 @@ ProcRenderTriStrip (ClientPtr client)
return BadMatch;
if (stuff->maskFormat)
{
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->maskFormat,
- PictFormatType,
- DixReadAccess);
- if (!pFormat)
- {
- client->errorValue = stuff->maskFormat;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
}
else
pFormat = 0;
@@ -882,7 +859,7 @@ ProcRenderTriStrip (ClientPtr client)
static int
ProcRenderTriFan (ClientPtr client)
{
- int npoints;
+ int rc, npoints;
PicturePtr pSrc, pDst;
PictFormatPtr pFormat;
REQUEST(xRenderTrianglesReq);
@@ -903,15 +880,10 @@ ProcRenderTriFan (ClientPtr client)
return BadMatch;
if (stuff->maskFormat)
{
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->maskFormat,
- PictFormatType,
- DixReadAccess);
- if (!pFormat)
- {
- client->errorValue = stuff->maskFormat;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
}
else
pFormat = 0;
@@ -955,15 +927,11 @@ ProcRenderCreateGlyphSet (ClientPtr client)
REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
LEGAL_NEW_RESOURCE(stuff->gsid, client);
- format = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->format,
- PictFormatType,
- DixReadAccess);
- if (!format)
- {
- client->errorValue = stuff->format;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&format, stuff->format,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
+
switch (format->depth) {
case 1:
f = GlyphFormat1;
@@ -1269,7 +1237,7 @@ ProcRenderFreeGlyphs (ClientPtr client)
client->errorValue = stuff->glyphset;
return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
}
- nglyph = ((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq)) >> 2;
+ nglyph = bytes_to_int32((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq));
gids = (CARD32 *) (stuff + 1);
while (nglyph-- > 0)
{
@@ -1301,7 +1269,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
int nlist;
int space;
int size;
- int n;
+ int rc, n;
REQUEST(xRenderCompositeGlyphsReq);
@@ -1328,28 +1296,18 @@ ProcRenderCompositeGlyphs (ClientPtr client)
return BadMatch;
if (stuff->maskFormat)
{
- pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
- stuff->maskFormat,
- PictFormatType,
- DixReadAccess);
- if (!pFormat)
- {
- client->errorValue = stuff->maskFormat;
- return RenderErrBase + BadPictFormat;
- }
+ rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat,
+ PictFormatType, client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadPictFormat : rc;
}
else
pFormat = 0;
- glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
- stuff->glyphset,
- GlyphSetType,
- DixUseAccess);
- if (!glyphSet)
- {
- client->errorValue = stuff->glyphset;
- return RenderErrBase + BadGlyphSet;
- }
+ rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset,
+ GlyphSetType, client, DixUseAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
buffer = (CARD8 *) (stuff + 1);
end = (CARD8 *) stuff + (client->req_len << 2);
@@ -1403,18 +1361,16 @@ ProcRenderCompositeGlyphs (ClientPtr client)
if (buffer + sizeof (GlyphSet) < end)
{
memcpy(&gs, buffer, sizeof(GlyphSet));
- glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
- gs,
- GlyphSetType,
- DixUseAccess);
- if (!glyphSet)
+ rc = dixLookupResourceByType((pointer *)&glyphSet, gs,
+ GlyphSetType, client,
+ DixUseAccess);
+ if (rc != Success)
{
- client->errorValue = gs;
if (glyphsBase != glyphsLocal)
xfree (glyphsBase);
if (listsBase != listsLocal)
xfree (listsBase);
- return RenderErrBase + BadGlyphSet;
+ return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
}
}
buffer += 4;
@@ -1507,7 +1463,7 @@ ProcRenderFillRectangles (ClientPtr client)
}
static void
-SetBit (unsigned char *line, int x, int bit)
+RenderSetBit (unsigned char *line, int x, int bit)
{
unsigned char mask;
@@ -1678,8 +1634,8 @@ ProcRenderCreateCursor (ClientPtr client)
{
CARD32 a = ((p >> 24));
- SetBit (mskline, x, a != 0);
- SetBit (srcline, x, a != 0 && p == twocolor[0]);
+ RenderSetBit (mskline, x, a != 0);
+ RenderSetBit (srcline, x, a != 0 && p == twocolor[0]);
}
else
{
@@ -1687,9 +1643,9 @@ ProcRenderCreateCursor (ClientPtr client)
CARD32 i = ((CvtR8G8B8toY15(p) >> 7) * DITHER_SIZE + 127) / 255;
CARD32 d = orderedDither[y&(DITHER_DIM-1)][x&(DITHER_DIM-1)];
/* Set mask from dithered alpha value */
- SetBit(mskline, x, a > d);
+ RenderSetBit(mskline, x, a > d);
/* Set src from dithered intensity value */
- SetBit(srcline, x, a > d && i <= d);
+ RenderSetBit(srcline, x, a > d && i <= d);
}
}
srcline += stride;
@@ -1781,7 +1737,7 @@ ProcRenderQueryFilters (ClientPtr client)
nbytesName += 1 + strlen (ps->filterAliases[i].alias);
nnames = ps->nfilters + ps->nfilterAliases;
}
- len = ((nnames + 1) >> 1) + ((nbytesName + 3) >> 2);
+ len = ((nnames + 1) >> 1) + bytes_to_int32(nbytesName);
total_bytes = sizeof (xRenderQueryFiltersReply) + (len << 2);
reply = (xRenderQueryFiltersReply *) xalloc (total_bytes);
if (!reply)
@@ -1873,7 +1829,7 @@ ProcRenderSetPictureFilter (ClientPtr client)
VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess,
RenderErrBase + BadPicture);
name = (char *) (stuff + 1);
- params = (xFixed *) (name + ((stuff->nbytes + 3) & ~3));
+ params = (xFixed *) (name + pad_to_int32(stuff->nbytes));
nparams = ((xFixed *) stuff + client->req_len) - params;
result = SetPictureFilter (pPicture, name, stuff->nbytes, params, nparams);
return result;
@@ -1895,7 +1851,7 @@ ProcRenderCreateAnimCursor (ClientPtr client)
LEGAL_NEW_RESOURCE(stuff->cid, client);
if (client->req_len & 1)
return BadLength;
- ncursor = (client->req_len - (SIZEOF(xRenderCreateAnimCursorReq) >> 2)) >> 1;
+ ncursor = (client->req_len - (bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1;
cursors = xalloc (ncursor * (sizeof (CursorPtr) + sizeof (CARD32)));
if (!cursors)
return BadAlloc;
@@ -1903,13 +1859,12 @@ ProcRenderCreateAnimCursor (ClientPtr client)
elt = (xAnimCursorElt *) (stuff + 1);
for (i = 0; i < ncursor; i++)
{
- cursors[i] = (CursorPtr)SecurityLookupIDByType(client, elt->cursor,
- RT_CURSOR, DixReadAccess);
- if (!cursors[i])
+ ret = dixLookupResourceByType((pointer *)(cursors + i), elt->cursor,
+ RT_CURSOR, client, DixReadAccess);
+ if (ret != Success)
{
xfree (cursors);
- client->errorValue = elt->cursor;
- return BadCursor;
+ return (ret == BadValue) ? BadCursor : ret;
}
deltas[i] = elt->delay;
elt++;
@@ -2690,11 +2645,10 @@ SProcRenderDispatch (ClientPtr client)
#include "panoramiXsrv.h"
#define VERIFY_XIN_PICTURE(pPicture, pid, client, mode, err) {\
- pPicture = SecurityLookupIDByType(client, pid, XRT_PICTURE, mode);\
- if (!pPicture) { \
- client->errorValue = pid; \
- return err; \
- } \
+ int rc = dixLookupResourceByType((pointer *)&(pPicture), pid,\
+ XRT_PICTURE, client, mode);\
+ if (rc != Success)\
+ return (rc == BadValue) ? err : rc;\
}
#define VERIFY_XIN_ALPHA(pPicture, pid, client, mode, err) {\
@@ -2714,12 +2668,13 @@ PanoramiXRenderCreatePicture (ClientPtr client)
{
REQUEST(xRenderCreatePictureReq);
PanoramiXRes *refDraw, *newPict;
- int result = Success, j;
+ int result, j;
REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
- if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass(
- client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
- return BadDrawable;
+ result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable,
+ XRC_DRAWABLE, client, DixWriteAccess);
+ if (result != Success)
+ return (result == BadValue) ? BadDrawable : result;
if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
return BadAlloc;
newPict->type = XRT_PICTURE;