3
* Copyright Ā© 2000 SuSE, Inc.
5
* Permission to use, copy, modify, distribute, and sell this software and its
6
* documentation for any purpose is hereby granted without fee, provided that
7
* the above copyright notice appear in all copies and that both that
8
* copyright notice and this permission notice appear in supporting
9
* documentation, and that the name of SuSE not be used in advertising or
10
* publicity pertaining to distribution of the software without specific,
11
* written prior permission. SuSE makes no representations about the
12
* suitability of this software for any purpose. It is provided "as is"
13
* without express or implied warranty.
15
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
16
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
17
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
19
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
* Author: Keith Packard, SuSE, Inc.
25
#ifdef HAVE_DIX_CONFIG_H
26
#include <dix-config.h>
30
#include <X11/Xproto.h>
33
#include "dixstruct.h"
35
#include "scrnintstr.h"
36
#include "windowstr.h"
37
#include "pixmapstr.h"
38
#include "colormapst.h"
39
#include "extnsionst.h"
42
#include <X11/extensions/render.h>
43
#include <X11/extensions/renderproto.h>
44
#include "picturestr.h"
46
#include <X11/Xfuncproto.h>
47
#include "cursorstr.h"
49
#include "protocol-versions.h"
52
#include "panoramiX.h"
53
#include "panoramiXsrv.h"
58
static int ProcRenderQueryVersion(ClientPtr pClient);
59
static int ProcRenderQueryPictFormats(ClientPtr pClient);
60
static int ProcRenderQueryPictIndexValues(ClientPtr pClient);
61
static int ProcRenderQueryDithers(ClientPtr pClient);
62
static int ProcRenderCreatePicture(ClientPtr pClient);
63
static int ProcRenderChangePicture(ClientPtr pClient);
64
static int ProcRenderSetPictureClipRectangles(ClientPtr pClient);
65
static int ProcRenderFreePicture(ClientPtr pClient);
66
static int ProcRenderComposite(ClientPtr pClient);
67
static int ProcRenderScale(ClientPtr pClient);
68
static int ProcRenderTrapezoids(ClientPtr pClient);
69
static int ProcRenderTriangles(ClientPtr pClient);
70
static int ProcRenderTriStrip(ClientPtr pClient);
71
static int ProcRenderTriFan(ClientPtr pClient);
72
static int ProcRenderColorTrapezoids(ClientPtr pClient);
73
static int ProcRenderColorTriangles(ClientPtr pClient);
74
static int ProcRenderTransform(ClientPtr pClient);
75
static int ProcRenderCreateGlyphSet(ClientPtr pClient);
76
static int ProcRenderReferenceGlyphSet(ClientPtr pClient);
77
static int ProcRenderFreeGlyphSet(ClientPtr pClient);
78
static int ProcRenderAddGlyphs(ClientPtr pClient);
79
static int ProcRenderAddGlyphsFromPicture(ClientPtr pClient);
80
static int ProcRenderFreeGlyphs(ClientPtr pClient);
81
static int ProcRenderCompositeGlyphs(ClientPtr pClient);
82
static int ProcRenderFillRectangles(ClientPtr pClient);
83
static int ProcRenderCreateCursor(ClientPtr pClient);
84
static int ProcRenderSetPictureTransform(ClientPtr pClient);
85
static int ProcRenderQueryFilters(ClientPtr pClient);
86
static int ProcRenderSetPictureFilter(ClientPtr pClient);
87
static int ProcRenderCreateAnimCursor(ClientPtr pClient);
88
static int ProcRenderAddTraps(ClientPtr pClient);
89
static int ProcRenderCreateSolidFill(ClientPtr pClient);
90
static int ProcRenderCreateLinearGradient(ClientPtr pClient);
91
static int ProcRenderCreateRadialGradient(ClientPtr pClient);
92
static int ProcRenderCreateConicalGradient(ClientPtr pClient);
94
static int ProcRenderDispatch(ClientPtr pClient);
96
static int SProcRenderQueryVersion(ClientPtr pClient);
97
static int SProcRenderQueryPictFormats(ClientPtr pClient);
98
static int SProcRenderQueryPictIndexValues(ClientPtr pClient);
99
static int SProcRenderQueryDithers(ClientPtr pClient);
100
static int SProcRenderCreatePicture(ClientPtr pClient);
101
static int SProcRenderChangePicture(ClientPtr pClient);
102
static int SProcRenderSetPictureClipRectangles(ClientPtr pClient);
103
static int SProcRenderFreePicture(ClientPtr pClient);
104
static int SProcRenderComposite(ClientPtr pClient);
105
static int SProcRenderScale(ClientPtr pClient);
106
static int SProcRenderTrapezoids(ClientPtr pClient);
107
static int SProcRenderTriangles(ClientPtr pClient);
108
static int SProcRenderTriStrip(ClientPtr pClient);
109
static int SProcRenderTriFan(ClientPtr pClient);
110
static int SProcRenderColorTrapezoids(ClientPtr pClient);
111
static int SProcRenderColorTriangles(ClientPtr pClient);
112
static int SProcRenderTransform(ClientPtr pClient);
113
static int SProcRenderCreateGlyphSet(ClientPtr pClient);
114
static int SProcRenderReferenceGlyphSet(ClientPtr pClient);
115
static int SProcRenderFreeGlyphSet(ClientPtr pClient);
116
static int SProcRenderAddGlyphs(ClientPtr pClient);
117
static int SProcRenderAddGlyphsFromPicture(ClientPtr pClient);
118
static int SProcRenderFreeGlyphs(ClientPtr pClient);
119
static int SProcRenderCompositeGlyphs(ClientPtr pClient);
120
static int SProcRenderFillRectangles(ClientPtr pClient);
121
static int SProcRenderCreateCursor(ClientPtr pClient);
122
static int SProcRenderSetPictureTransform(ClientPtr pClient);
123
static int SProcRenderQueryFilters(ClientPtr pClient);
124
static int SProcRenderSetPictureFilter(ClientPtr pClient);
125
static int SProcRenderCreateAnimCursor(ClientPtr pClient);
126
static int SProcRenderAddTraps(ClientPtr pClient);
127
static int SProcRenderCreateSolidFill(ClientPtr pClient);
128
static int SProcRenderCreateLinearGradient(ClientPtr pClient);
129
static int SProcRenderCreateRadialGradient(ClientPtr pClient);
130
static int SProcRenderCreateConicalGradient(ClientPtr pClient);
132
static int SProcRenderDispatch(ClientPtr pClient);
134
int (*ProcRenderVector[RenderNumberRequests]) (ClientPtr) = {
135
ProcRenderQueryVersion,
136
ProcRenderQueryPictFormats,
137
ProcRenderQueryPictIndexValues,
138
ProcRenderQueryDithers,
139
ProcRenderCreatePicture,
140
ProcRenderChangePicture,
141
ProcRenderSetPictureClipRectangles,
142
ProcRenderFreePicture,
145
ProcRenderTrapezoids,
149
ProcRenderColorTrapezoids,
150
ProcRenderColorTriangles,
152
ProcRenderCreateGlyphSet,
153
ProcRenderReferenceGlyphSet,
154
ProcRenderFreeGlyphSet,
156
ProcRenderAddGlyphsFromPicture,
157
ProcRenderFreeGlyphs,
158
ProcRenderCompositeGlyphs,
159
ProcRenderCompositeGlyphs,
160
ProcRenderCompositeGlyphs,
161
ProcRenderFillRectangles,
162
ProcRenderCreateCursor,
163
ProcRenderSetPictureTransform,
164
ProcRenderQueryFilters,
165
ProcRenderSetPictureFilter,
166
ProcRenderCreateAnimCursor,
168
ProcRenderCreateSolidFill,
169
ProcRenderCreateLinearGradient,
170
ProcRenderCreateRadialGradient, ProcRenderCreateConicalGradient};
172
int (*SProcRenderVector[RenderNumberRequests]) (ClientPtr) = {
173
SProcRenderQueryVersion,
174
SProcRenderQueryPictFormats,
175
SProcRenderQueryPictIndexValues,
176
SProcRenderQueryDithers,
177
SProcRenderCreatePicture,
178
SProcRenderChangePicture,
179
SProcRenderSetPictureClipRectangles,
180
SProcRenderFreePicture,
181
SProcRenderComposite,
183
SProcRenderTrapezoids,
184
SProcRenderTriangles,
187
SProcRenderColorTrapezoids,
188
SProcRenderColorTriangles,
189
SProcRenderTransform,
190
SProcRenderCreateGlyphSet,
191
SProcRenderReferenceGlyphSet,
192
SProcRenderFreeGlyphSet,
193
SProcRenderAddGlyphs,
194
SProcRenderAddGlyphsFromPicture,
195
SProcRenderFreeGlyphs,
196
SProcRenderCompositeGlyphs,
197
SProcRenderCompositeGlyphs,
198
SProcRenderCompositeGlyphs,
199
SProcRenderFillRectangles,
200
SProcRenderCreateCursor,
201
SProcRenderSetPictureTransform,
202
SProcRenderQueryFilters,
203
SProcRenderSetPictureFilter,
204
SProcRenderCreateAnimCursor,
206
SProcRenderCreateSolidFill,
207
SProcRenderCreateLinearGradient,
208
SProcRenderCreateRadialGradient, SProcRenderCreateConicalGradient};
211
static DevPrivateKeyRec RenderClientPrivateKeyRec;
213
#define RenderClientPrivateKey (&RenderClientPrivateKeyRec )
215
typedef struct _RenderClient {
218
} RenderClientRec, *RenderClientPtr;
220
#define GetRenderClient(pClient) ((RenderClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RenderClientPrivateKey))
223
RenderClientCallback(CallbackListPtr *list, void *closure, void *data)
225
NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
226
ClientPtr pClient = clientinfo->client;
227
RenderClientPtr pRenderClient = GetRenderClient(pClient);
229
pRenderClient->major_version = 0;
230
pRenderClient->minor_version = 0;
238
RenderExtensionInit(void)
240
ExtensionEntry *extEntry;
244
if (!PictureFinishInit())
246
if (!dixRegisterPrivateKey
247
(&RenderClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(RenderClientRec)))
249
if (!AddCallback(&ClientStateCallback, RenderClientCallback, 0))
252
extEntry = AddExtension(RENDER_NAME, 0, RenderNumberErrors,
253
ProcRenderDispatch, SProcRenderDispatch,
254
NULL, StandardMinorOpcode);
257
RenderErrBase = extEntry->errorBase;
260
SetResourceTypeErrorValue(XRT_PICTURE, RenderErrBase + BadPicture);
262
SetResourceTypeErrorValue(PictureType, RenderErrBase + BadPicture);
263
SetResourceTypeErrorValue(PictFormatType, RenderErrBase + BadPictFormat);
264
SetResourceTypeErrorValue(GlyphSetType, RenderErrBase + BadGlyphSet);
268
ProcRenderQueryVersion(ClientPtr client)
270
RenderClientPtr pRenderClient = GetRenderClient(client);
271
xRenderQueryVersionReply rep = {
273
.sequenceNumber = client->sequence,
277
REQUEST(xRenderQueryVersionReq);
279
REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
281
pRenderClient->major_version = stuff->majorVersion;
282
pRenderClient->minor_version = stuff->minorVersion;
284
if ((stuff->majorVersion * 1000 + stuff->minorVersion) <
285
(SERVER_RENDER_MAJOR_VERSION * 1000 + SERVER_RENDER_MINOR_VERSION)) {
286
rep.majorVersion = stuff->majorVersion;
287
rep.minorVersion = stuff->minorVersion;
290
rep.majorVersion = SERVER_RENDER_MAJOR_VERSION;
291
rep.minorVersion = SERVER_RENDER_MINOR_VERSION;
294
if (client->swapped) {
295
swaps(&rep.sequenceNumber);
297
swapl(&rep.majorVersion);
298
swapl(&rep.minorVersion);
300
WriteToClient(client, sizeof(xRenderQueryVersionReply), &rep);
305
findVisual(ScreenPtr pScreen, VisualID vid)
310
for (v = 0; v < pScreen->numVisuals; v++) {
311
pVisual = pScreen->visuals + v;
312
if (pVisual->vid == vid)
319
ProcRenderQueryPictFormats(ClientPtr client)
321
RenderClientPtr pRenderClient = GetRenderClient(client);
322
xRenderQueryPictFormatsReply *reply;
323
xPictScreen *pictScreen;
324
xPictDepth *pictDepth;
325
xPictVisual *pictVisual;
326
xPictFormInfo *pictForm;
327
CARD32 *pictSubpixel;
333
PictFormatPtr pFormat;
342
/* REQUEST(xRenderQueryPictFormatsReq); */
344
REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq);
347
if (noPanoramiXExtension)
348
numScreens = screenInfo.numScreens;
350
numScreens = ((xConnSetup *) ConnectionInfo)->numRoots;
352
numScreens = screenInfo.numScreens;
354
ndepth = nformat = nvisual = 0;
355
for (s = 0; s < numScreens; s++) {
356
pScreen = screenInfo.screens[s];
357
for (d = 0; d < pScreen->numDepths; d++) {
358
pDepth = pScreen->allowedDepths + d;
361
for (v = 0; v < pDepth->numVids; v++) {
362
pVisual = findVisual(pScreen, pDepth->vids[v]);
364
PictureMatchVisual(pScreen, pDepth->depth, pVisual))
368
ps = GetPictureScreenIfSet(pScreen);
370
nformat += ps->nformats;
372
if (pRenderClient->major_version == 0 && pRenderClient->minor_version < 6)
375
numSubpixel = numScreens;
377
rlength = (sizeof(xRenderQueryPictFormatsReply) +
378
nformat * sizeof(xPictFormInfo) +
379
numScreens * sizeof(xPictScreen) +
380
ndepth * sizeof(xPictDepth) +
381
nvisual * sizeof(xPictVisual) + numSubpixel * sizeof(CARD32));
382
reply = (xRenderQueryPictFormatsReply *) calloc(1, rlength);
385
reply->type = X_Reply;
386
reply->sequenceNumber = client->sequence;
387
reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
388
reply->numFormats = nformat;
389
reply->numScreens = numScreens;
390
reply->numDepths = ndepth;
391
reply->numVisuals = nvisual;
392
reply->numSubpixel = numSubpixel;
394
pictForm = (xPictFormInfo *) (reply + 1);
396
for (s = 0; s < numScreens; s++) {
397
pScreen = screenInfo.screens[s];
398
ps = GetPictureScreenIfSet(pScreen);
400
for (nformat = 0, pFormat = ps->formats;
401
nformat < ps->nformats; nformat++, pFormat++) {
402
pictForm->id = pFormat->id;
403
pictForm->type = pFormat->type;
404
pictForm->depth = pFormat->depth;
405
pictForm->direct.red = pFormat->direct.red;
406
pictForm->direct.redMask = pFormat->direct.redMask;
407
pictForm->direct.green = pFormat->direct.green;
408
pictForm->direct.greenMask = pFormat->direct.greenMask;
409
pictForm->direct.blue = pFormat->direct.blue;
410
pictForm->direct.blueMask = pFormat->direct.blueMask;
411
pictForm->direct.alpha = pFormat->direct.alpha;
412
pictForm->direct.alphaMask = pFormat->direct.alphaMask;
413
if (pFormat->type == PictTypeIndexed &&
414
pFormat->index.pColormap)
415
pictForm->colormap = pFormat->index.pColormap->mid;
417
pictForm->colormap = None;
418
if (client->swapped) {
419
swapl(&pictForm->id);
420
swaps(&pictForm->direct.red);
421
swaps(&pictForm->direct.redMask);
422
swaps(&pictForm->direct.green);
423
swaps(&pictForm->direct.greenMask);
424
swaps(&pictForm->direct.blue);
425
swaps(&pictForm->direct.blueMask);
426
swaps(&pictForm->direct.alpha);
427
swaps(&pictForm->direct.alphaMask);
428
swapl(&pictForm->colormap);
435
pictScreen = (xPictScreen *) pictForm;
436
for (s = 0; s < numScreens; s++) {
437
pScreen = screenInfo.screens[s];
438
pictDepth = (xPictDepth *) (pictScreen + 1);
440
for (d = 0; d < pScreen->numDepths; d++) {
441
pictVisual = (xPictVisual *) (pictDepth + 1);
442
pDepth = pScreen->allowedDepths + d;
445
for (v = 0; v < pDepth->numVids; v++) {
446
pVisual = findVisual(pScreen, pDepth->vids[v]);
447
if (pVisual && (pFormat = PictureMatchVisual(pScreen,
450
pictVisual->visual = pVisual->vid;
451
pictVisual->format = pFormat->id;
452
if (client->swapped) {
453
swapl(&pictVisual->visual);
454
swapl(&pictVisual->format);
460
pictDepth->depth = pDepth->depth;
461
pictDepth->nPictVisuals = nvisual;
462
if (client->swapped) {
463
swaps(&pictDepth->nPictVisuals);
466
pictDepth = (xPictDepth *) pictVisual;
468
pictScreen->nDepth = ndepth;
469
ps = GetPictureScreenIfSet(pScreen);
471
pictScreen->fallback = ps->fallback->id;
473
pictScreen->fallback = 0;
474
if (client->swapped) {
475
swapl(&pictScreen->nDepth);
476
swapl(&pictScreen->fallback);
478
pictScreen = (xPictScreen *) pictDepth;
480
pictSubpixel = (CARD32 *) pictScreen;
482
for (s = 0; s < numSubpixel; s++) {
483
pScreen = screenInfo.screens[s];
484
ps = GetPictureScreenIfSet(pScreen);
486
*pictSubpixel = ps->subpixel;
488
*pictSubpixel = SubPixelUnknown;
489
if (client->swapped) {
495
if (client->swapped) {
496
swaps(&reply->sequenceNumber);
497
swapl(&reply->length);
498
swapl(&reply->numFormats);
499
swapl(&reply->numScreens);
500
swapl(&reply->numDepths);
501
swapl(&reply->numVisuals);
502
swapl(&reply->numSubpixel);
504
WriteToClient(client, rlength, reply);
510
ProcRenderQueryPictIndexValues(ClientPtr client)
512
PictFormatPtr pFormat;
517
REQUEST(xRenderQueryPictIndexValuesReq);
518
xRenderQueryPictIndexValuesReply *reply;
521
REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq);
523
rc = dixLookupResourceByType((void **) &pFormat, stuff->format,
524
PictFormatType, client, DixReadAccess);
528
if (pFormat->type != PictTypeIndexed) {
529
client->errorValue = stuff->format;
532
num = pFormat->index.nvalues;
533
rlength = (sizeof(xRenderQueryPictIndexValuesReply) +
534
num * sizeof(xIndexValue));
535
reply = (xRenderQueryPictIndexValuesReply *) calloc(1, rlength);
539
reply->type = X_Reply;
540
reply->sequenceNumber = client->sequence;
541
reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
542
reply->numIndexValues = num;
544
values = (xIndexValue *) (reply + 1);
546
memcpy(reply + 1, pFormat->index.pValues, num * sizeof(xIndexValue));
548
if (client->swapped) {
549
for (i = 0; i < num; i++) {
550
swapl(&values[i].pixel);
551
swaps(&values[i].red);
552
swaps(&values[i].green);
553
swaps(&values[i].blue);
554
swaps(&values[i].alpha);
556
swaps(&reply->sequenceNumber);
557
swapl(&reply->length);
558
swapl(&reply->numIndexValues);
561
WriteToClient(client, rlength, reply);
567
ProcRenderQueryDithers(ClientPtr client)
569
return BadImplementation;
573
ProcRenderCreatePicture(ClientPtr client)
576
DrawablePtr pDrawable;
577
PictFormatPtr pFormat;
580
REQUEST(xRenderCreatePictureReq);
582
REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
584
LEGAL_NEW_RESOURCE(stuff->pid, client);
585
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
586
DixReadAccess | DixAddAccess);
590
rc = dixLookupResourceByType((void **) &pFormat, stuff->format,
591
PictFormatType, client, DixReadAccess);
595
if (pFormat->depth != pDrawable->depth)
597
len = client->req_len - bytes_to_int32(sizeof(xRenderCreatePictureReq));
598
if (Ones(stuff->mask) != len)
601
pPicture = CreatePicture(stuff->pid,
604
stuff->mask, (XID *) (stuff + 1), client, &error);
607
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
613
ProcRenderChangePicture(ClientPtr client)
617
REQUEST(xRenderChangePictureReq);
620
REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
621
VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
623
len = client->req_len - bytes_to_int32(sizeof(xRenderChangePictureReq));
624
if (Ones(stuff->mask) != len)
627
return ChangePicture(pPicture, stuff->mask, (XID *) (stuff + 1),
628
(DevUnion *) 0, client);
632
ProcRenderSetPictureClipRectangles(ClientPtr client)
634
REQUEST(xRenderSetPictureClipRectanglesReq);
638
REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
639
VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
640
if (!pPicture->pDrawable)
641
return RenderErrBase + BadPicture;
643
nr = (client->req_len << 2) - sizeof(xRenderSetPictureClipRectanglesReq);
647
return SetPictureClipRects(pPicture,
648
stuff->xOrigin, stuff->yOrigin,
649
nr, (xRectangle *) &stuff[1]);
653
ProcRenderFreePicture(ClientPtr client)
657
REQUEST(xRenderFreePictureReq);
659
REQUEST_SIZE_MATCH(xRenderFreePictureReq);
661
VERIFY_PICTURE(pPicture, stuff->picture, client, DixDestroyAccess);
662
FreeResource(stuff->picture, RT_NONE);
667
PictOpValid(CARD8 op)
669
if ( /*PictOpMinimum <= op && */ op <= PictOpMaximum)
671
if (PictOpDisjointMinimum <= op && op <= PictOpDisjointMaximum)
673
if (PictOpConjointMinimum <= op && op <= PictOpConjointMaximum)
675
if (PictOpBlendMinimum <= op && op <= PictOpBlendMaximum)
681
ProcRenderComposite(ClientPtr client)
683
PicturePtr pSrc, pMask, pDst;
685
REQUEST(xRenderCompositeReq);
687
REQUEST_SIZE_MATCH(xRenderCompositeReq);
688
if (!PictOpValid(stuff->op)) {
689
client->errorValue = stuff->op;
692
VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
693
if (!pDst->pDrawable)
695
VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
696
VERIFY_ALPHA(pMask, stuff->mask, client, DixReadAccess);
697
if ((pSrc->pDrawable &&
698
pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) || (pMask &&
708
CompositePicture(stuff->op,
716
stuff->xDst, stuff->yDst, stuff->width, stuff->height);
721
ProcRenderScale(ClientPtr client)
723
return BadImplementation;
727
ProcRenderTrapezoids(ClientPtr client)
730
PicturePtr pSrc, pDst;
731
PictFormatPtr pFormat;
733
REQUEST(xRenderTrapezoidsReq);
735
REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq);
736
if (!PictOpValid(stuff->op)) {
737
client->errorValue = stuff->op;
740
VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
741
VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
742
if (!pDst->pDrawable)
744
if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
746
if (stuff->maskFormat) {
747
rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat,
748
PictFormatType, client, DixReadAccess);
754
ntraps = (client->req_len << 2) - sizeof(xRenderTrapezoidsReq);
755
if (ntraps % sizeof(xTrapezoid))
757
ntraps /= sizeof(xTrapezoid);
759
CompositeTrapezoids(stuff->op, pSrc, pDst, pFormat,
760
stuff->xSrc, stuff->ySrc,
761
ntraps, (xTrapezoid *) &stuff[1]);
766
ProcRenderTriangles(ClientPtr client)
769
PicturePtr pSrc, pDst;
770
PictFormatPtr pFormat;
772
REQUEST(xRenderTrianglesReq);
774
REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
775
if (!PictOpValid(stuff->op)) {
776
client->errorValue = stuff->op;
779
VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
780
VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
781
if (!pDst->pDrawable)
783
if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
785
if (stuff->maskFormat) {
786
rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat,
787
PictFormatType, client, DixReadAccess);
793
ntris = (client->req_len << 2) - sizeof(xRenderTrianglesReq);
794
if (ntris % sizeof(xTriangle))
796
ntris /= sizeof(xTriangle);
798
CompositeTriangles(stuff->op, pSrc, pDst, pFormat,
799
stuff->xSrc, stuff->ySrc,
800
ntris, (xTriangle *) &stuff[1]);
805
ProcRenderTriStrip(ClientPtr client)
808
PicturePtr pSrc, pDst;
809
PictFormatPtr pFormat;
811
REQUEST(xRenderTrianglesReq);
813
REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
814
if (!PictOpValid(stuff->op)) {
815
client->errorValue = stuff->op;
818
VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
819
VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
820
if (!pDst->pDrawable)
822
if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
824
if (stuff->maskFormat) {
825
rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat,
826
PictFormatType, client, DixReadAccess);
832
npoints = ((client->req_len << 2) - sizeof(xRenderTriStripReq));
837
CompositeTriStrip(stuff->op, pSrc, pDst, pFormat,
838
stuff->xSrc, stuff->ySrc,
839
npoints, (xPointFixed *) &stuff[1]);
844
ProcRenderTriFan(ClientPtr client)
847
PicturePtr pSrc, pDst;
848
PictFormatPtr pFormat;
850
REQUEST(xRenderTrianglesReq);
852
REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
853
if (!PictOpValid(stuff->op)) {
854
client->errorValue = stuff->op;
857
VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
858
VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
859
if (!pDst->pDrawable)
861
if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
863
if (stuff->maskFormat) {
864
rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat,
865
PictFormatType, client, DixReadAccess);
871
npoints = ((client->req_len << 2) - sizeof(xRenderTriStripReq));
876
CompositeTriFan(stuff->op, pSrc, pDst, pFormat,
877
stuff->xSrc, stuff->ySrc,
878
npoints, (xPointFixed *) &stuff[1]);
883
ProcRenderColorTrapezoids(ClientPtr client)
885
return BadImplementation;
889
ProcRenderColorTriangles(ClientPtr client)
891
return BadImplementation;
895
ProcRenderTransform(ClientPtr client)
897
return BadImplementation;
901
ProcRenderCreateGlyphSet(ClientPtr client)
903
GlyphSetPtr glyphSet;
904
PictFormatPtr format;
907
REQUEST(xRenderCreateGlyphSetReq);
909
REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
911
LEGAL_NEW_RESOURCE(stuff->gsid, client);
912
rc = dixLookupResourceByType((void **) &format, stuff->format,
913
PictFormatType, client, DixReadAccess);
917
switch (format->depth) {
936
if (format->type != PictTypeDirect)
938
glyphSet = AllocateGlyphSet(f, format);
941
/* security creation/labeling check */
942
rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->gsid, GlyphSetType,
943
glyphSet, RT_NONE, NULL, DixCreateAccess);
946
if (!AddResource(stuff->gsid, GlyphSetType, (void *) glyphSet))
952
ProcRenderReferenceGlyphSet(ClientPtr client)
954
GlyphSetPtr glyphSet;
957
REQUEST(xRenderReferenceGlyphSetReq);
959
REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq);
961
LEGAL_NEW_RESOURCE(stuff->gsid, client);
963
rc = dixLookupResourceByType((void **) &glyphSet, stuff->existing,
964
GlyphSetType, client, DixGetAttrAccess);
966
client->errorValue = stuff->existing;
970
if (!AddResource(stuff->gsid, GlyphSetType, (void *) glyphSet))
975
#define NLOCALDELTA 64
976
#define NLOCALGLYPH 256
979
ProcRenderFreeGlyphSet(ClientPtr client)
981
GlyphSetPtr glyphSet;
984
REQUEST(xRenderFreeGlyphSetReq);
986
REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
987
rc = dixLookupResourceByType((void **) &glyphSet, stuff->glyphset,
988
GlyphSetType, client, DixDestroyAccess);
990
client->errorValue = stuff->glyphset;
993
FreeResource(stuff->glyphset, RT_NONE);
997
typedef struct _GlyphNew {
1001
unsigned char sha1[20];
1002
} GlyphNewRec, *GlyphNewPtr;
1004
#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
1007
ProcRenderAddGlyphs(ClientPtr client)
1009
GlyphSetPtr glyphSet;
1011
REQUEST(xRenderAddGlyphsReq);
1012
GlyphNewRec glyphsLocal[NLOCALGLYPH];
1013
GlyphNewPtr glyphsBase, glyphs, glyph_new;
1014
int remain, nglyphs;
1021
PicturePtr pSrc = NULL, pDst = NULL;
1022
PixmapPtr pSrcPix = NULL, pDstPix = NULL;
1023
CARD32 component_alpha;
1025
REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
1027
dixLookupResourceByType((void **) &glyphSet, stuff->glyphset,
1028
GlyphSetType, client, DixAddAccess);
1029
if (err != Success) {
1030
client->errorValue = stuff->glyphset;
1035
nglyphs = stuff->nglyphs;
1036
if (nglyphs > UINT32_MAX / sizeof(GlyphNewRec))
1039
component_alpha = NeedsComponent(glyphSet->format->format);
1041
if (nglyphs <= NLOCALGLYPH) {
1042
memset(glyphsLocal, 0, sizeof(glyphsLocal));
1043
glyphsBase = glyphsLocal;
1046
glyphsBase = (GlyphNewPtr) calloc(nglyphs, sizeof(GlyphNewRec));
1051
remain = (client->req_len << 2) - sizeof(xRenderAddGlyphsReq);
1053
glyphs = glyphsBase;
1055
gids = (CARD32 *) (stuff + 1);
1056
gi = (xGlyphInfo *) (gids + nglyphs);
1057
bits = (CARD8 *) (gi + nglyphs);
1058
remain -= (sizeof(CARD32) + sizeof(xGlyphInfo)) * nglyphs;
1060
/* protect against bad nglyphs */
1061
if (gi < ((xGlyphInfo *) stuff) ||
1062
gi > ((xGlyphInfo *) ((CARD32 *) stuff + client->req_len)) ||
1063
bits < ((CARD8 *) stuff) ||
1064
bits > ((CARD8 *) ((CARD32 *) stuff + client->req_len))) {
1069
for (i = 0; i < nglyphs; i++) {
1070
size_t padded_width;
1072
glyph_new = &glyphs[i];
1074
padded_width = PixmapBytePad(gi[i].width, glyphSet->format->depth);
1077
padded_width > (UINT32_MAX - sizeof(GlyphRec)) / gi[i].height)
1080
size = gi[i].height * padded_width;
1084
err = HashGlyph(&gi[i], bits, size, glyph_new->sha1);
1088
glyph_new->glyph = FindGlyphByHash(glyph_new->sha1, glyphSet->fdepth);
1090
if (glyph_new->glyph && glyph_new->glyph != DeletedGlyph) {
1091
glyph_new->found = TRUE;
1096
glyph_new->found = FALSE;
1097
glyph_new->glyph = glyph = AllocateGlyph(&gi[i], glyphSet->fdepth);
1103
for (screen = 0; screen < screenInfo.numScreens; screen++) {
1104
int width = gi[i].width;
1105
int height = gi[i].height;
1106
int depth = glyphSet->format->depth;
1110
/* Skip work if it's invisibly small anyway */
1111
if (!width || !height)
1114
pScreen = screenInfo.screens[screen];
1115
pSrcPix = GetScratchPixmapHeader(pScreen,
1117
depth, depth, -1, bits);
1123
pSrc = CreatePicture(0, &pSrcPix->drawable,
1124
glyphSet->format, 0, NULL,
1125
serverClient, &error);
1131
pDstPix = (pScreen->CreatePixmap) (pScreen,
1132
width, height, depth,
1133
CREATE_PIXMAP_USAGE_GLYPH_PICTURE);
1140
pDst = CreatePicture(0, &pDstPix->drawable,
1142
CPComponentAlpha, &component_alpha,
1143
serverClient, &error);
1144
SetGlyphPicture(glyph, pScreen, pDst);
1146
/* The picture takes a reference to the pixmap, so we
1148
(pScreen->DestroyPixmap) (pDstPix);
1156
CompositePicture(PictOpSrc,
1158
None, pDst, 0, 0, 0, 0, 0, 0, width, height);
1160
FreePicture((void *) pSrc, 0);
1162
FreeScratchPixmapHeader(pSrcPix);
1166
memcpy(glyph_new->glyph->sha1, glyph_new->sha1, 20);
1169
glyph_new->id = gids[i];
1172
size += 4 - (size & 3);
1176
if (remain || i < nglyphs) {
1180
if (!ResizeGlyphSet(glyphSet, nglyphs)) {
1184
for (i = 0; i < nglyphs; i++)
1185
AddGlyph(glyphSet, glyphs[i].glyph, glyphs[i].id);
1187
if (glyphsBase != glyphsLocal)
1192
FreePicture((void *) pSrc, 0);
1194
FreeScratchPixmapHeader(pSrcPix);
1195
for (i = 0; i < nglyphs; i++)
1196
if (glyphs[i].glyph && !glyphs[i].found)
1197
free(glyphs[i].glyph);
1198
if (glyphsBase != glyphsLocal)
1204
ProcRenderAddGlyphsFromPicture(ClientPtr client)
1206
return BadImplementation;
1210
ProcRenderFreeGlyphs(ClientPtr client)
1212
REQUEST(xRenderFreeGlyphsReq);
1213
GlyphSetPtr glyphSet;
1218
REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
1219
rc = dixLookupResourceByType((void **) &glyphSet, stuff->glyphset,
1220
GlyphSetType, client, DixRemoveAccess);
1221
if (rc != Success) {
1222
client->errorValue = stuff->glyphset;
1226
bytes_to_int32((client->req_len << 2) - sizeof(xRenderFreeGlyphsReq));
1227
gids = (CARD32 *) (stuff + 1);
1228
while (nglyph-- > 0) {
1230
if (!DeleteGlyph(glyphSet, glyph)) {
1231
client->errorValue = glyph;
1232
return RenderErrBase + BadGlyph;
1239
ProcRenderCompositeGlyphs(ClientPtr client)
1241
GlyphSetPtr glyphSet;
1243
PicturePtr pSrc, pDst;
1244
PictFormatPtr pFormat;
1245
GlyphListRec listsLocal[NLOCALDELTA];
1246
GlyphListPtr lists, listsBase;
1247
GlyphPtr glyphsLocal[NLOCALGLYPH];
1249
GlyphPtr *glyphs, *glyphsBase;
1251
CARD8 *buffer, *end;
1258
REQUEST(xRenderCompositeGlyphsReq);
1260
REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);
1262
switch (stuff->renderReqType) {
1266
case X_RenderCompositeGlyphs16:
1269
case X_RenderCompositeGlyphs32:
1274
if (!PictOpValid(stuff->op)) {
1275
client->errorValue = stuff->op;
1278
VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
1279
VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
1280
if (!pDst->pDrawable)
1282
if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
1284
if (stuff->maskFormat) {
1285
rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat,
1286
PictFormatType, client, DixReadAccess);
1293
rc = dixLookupResourceByType((void **) &glyphSet, stuff->glyphset,
1294
GlyphSetType, client, DixUseAccess);
1298
buffer = (CARD8 *) (stuff + 1);
1299
end = (CARD8 *) stuff + (client->req_len << 2);
1302
while (buffer + sizeof(xGlyphElt) < end) {
1303
elt = (xGlyphElt *) buffer;
1304
buffer += sizeof(xGlyphElt);
1306
if (elt->len == 0xff) {
1312
space = size * elt->len;
1314
space += 4 - (space & 3);
1318
if (nglyph <= NLOCALGLYPH)
1319
glyphsBase = glyphsLocal;
1321
glyphsBase = xallocarray(nglyph, sizeof(GlyphPtr));
1325
if (nlist <= NLOCALDELTA)
1326
listsBase = listsLocal;
1328
listsBase = xallocarray(nlist, sizeof(GlyphListRec));
1334
buffer = (CARD8 *) (stuff + 1);
1335
glyphs = glyphsBase;
1337
while (buffer + sizeof(xGlyphElt) < end) {
1338
elt = (xGlyphElt *) buffer;
1339
buffer += sizeof(xGlyphElt);
1341
if (elt->len == 0xff) {
1342
if (buffer + sizeof(GlyphSet) < end) {
1343
memcpy(&gs, buffer, sizeof(GlyphSet));
1344
rc = dixLookupResourceByType((void **) &glyphSet, gs,
1345
GlyphSetType, client,
1353
lists->xOff = elt->deltax;
1354
lists->yOff = elt->deltay;
1355
lists->format = glyphSet->format;
1359
if (buffer + size <= end) {
1362
glyph = *((CARD8 *) buffer);
1365
glyph = *((CARD16 *) buffer);
1369
glyph = *((CARD32 *) buffer);
1372
if ((*glyphs = FindGlyph(glyphSet, glyph))) {
1379
space = size * elt->len;
1381
buffer += 4 - (space & 3);
1390
CompositeGlyphs(stuff->op,
1394
stuff->xSrc, stuff->ySrc, nlist, listsBase, glyphsBase);
1398
if (glyphsBase != glyphsLocal)
1400
if (listsBase != listsLocal)
1406
ProcRenderFillRectangles(ClientPtr client)
1411
REQUEST(xRenderFillRectanglesReq);
1413
REQUEST_AT_LEAST_SIZE(xRenderFillRectanglesReq);
1414
if (!PictOpValid(stuff->op)) {
1415
client->errorValue = stuff->op;
1418
VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
1419
if (!pDst->pDrawable)
1422
things = (client->req_len << 2) - sizeof(xRenderFillRectanglesReq);
1427
CompositeRects(stuff->op,
1428
pDst, &stuff->color, things, (xRectangle *) &stuff[1]);
1434
RenderSetBit(unsigned char *line, int x, int bit)
1438
if (screenInfo.bitmapBitOrder == LSBFirst)
1439
mask = (1 << (x & 7));
1441
mask = (0x80 >> (x & 7));
1442
/* XXX assumes byte order is host byte order */
1450
#define DITHER_DIM 2
1452
static CARD32 orderedDither[DITHER_DIM][DITHER_DIM] = {
1457
#define DITHER_SIZE ((sizeof orderedDither / sizeof orderedDither[0][0]) + 1)
1460
ProcRenderCreateCursor(ClientPtr client)
1462
REQUEST(xRenderCreateCursorReq);
1465
unsigned short width, height;
1466
CARD32 *argbbits, *argb;
1467
unsigned char *srcbits, *srcline;
1468
unsigned char *mskbits, *mskline;
1477
REQUEST_SIZE_MATCH(xRenderCreateCursorReq);
1478
LEGAL_NEW_RESOURCE(stuff->cid, client);
1480
VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
1481
if (!pSrc->pDrawable)
1483
pScreen = pSrc->pDrawable->pScreen;
1484
width = pSrc->pDrawable->width;
1485
height = pSrc->pDrawable->height;
1486
if (height && width > UINT32_MAX / (height * sizeof(CARD32)))
1488
if (stuff->x > width || stuff->y > height)
1490
argbbits = malloc(width * height * sizeof(CARD32));
1494
stride = BitmapBytePad(width);
1495
nbytes_mono = stride * height;
1496
srcbits = calloc(1, nbytes_mono);
1501
mskbits = calloc(1, nbytes_mono);
1508
if (pSrc->format == PICT_a8r8g8b8) {
1509
(*pScreen->GetImage) (pSrc->pDrawable,
1510
0, 0, width, height, ZPixmap,
1511
0xffffffff, (void *) argbbits);
1515
PicturePtr pPicture;
1516
PictFormatPtr pFormat;
1519
pFormat = PictureMatchFormat(pScreen, 32, PICT_a8r8g8b8);
1524
return BadImplementation;
1526
pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 32,
1527
CREATE_PIXMAP_USAGE_SCRATCH);
1534
pPicture = CreatePicture(0, &pPixmap->drawable, pFormat, 0, 0,
1542
(*pScreen->DestroyPixmap) (pPixmap);
1543
CompositePicture(PictOpSrc,
1544
pSrc, 0, pPicture, 0, 0, 0, 0, 0, 0, width, height);
1545
(*pScreen->GetImage) (pPicture->pDrawable,
1546
0, 0, width, height, ZPixmap,
1547
0xffffffff, (void *) argbbits);
1548
FreePicture(pPicture, 0);
1551
* Check whether the cursor can be directly supported by
1552
* the core cursor code
1556
for (y = 0; ncolor <= 2 && y < height; y++) {
1557
for (x = 0; ncolor <= 2 && x < width; x++) {
1559
CARD32 a = (p >> 24);
1561
if (a == 0) /* transparent */
1563
if (a == 0xff) { /* opaque */
1566
for (n = 0; n < ncolor; n++)
1567
if (p == twocolor[n])
1570
twocolor[ncolor++] = p;
1578
* Convert argb image to two plane cursor
1583
for (y = 0; y < height; y++) {
1584
for (x = 0; x < width; x++) {
1588
CARD32 a = ((p >> 24));
1590
RenderSetBit(mskline, x, a != 0);
1591
RenderSetBit(srcline, x, a != 0 && p == twocolor[0]);
1594
CARD32 a = ((p >> 24) * DITHER_SIZE + 127) / 255;
1595
CARD32 i = ((CvtR8G8B8toY15(p) >> 7) * DITHER_SIZE + 127) / 255;
1597
orderedDither[y & (DITHER_DIM - 1)][x & (DITHER_DIM - 1)];
1598
/* Set mask from dithered alpha value */
1599
RenderSetBit(mskline, x, a > d);
1600
/* Set src from dithered intensity value */
1601
RenderSetBit(srcline, x, a > d && i <= d);
1608
* Dither to white and black if the cursor has more than two colors
1611
twocolor[0] = 0xff000000;
1612
twocolor[1] = 0xffffffff;
1619
#define GetByte(p,s) (((p) >> (s)) & 0xff)
1620
#define GetColor(p,s) (GetByte(p,s) | (GetByte(p,s) << 8))
1626
rc = AllocARGBCursor(srcbits, mskbits, argbbits, &cm,
1627
GetColor(twocolor[0], 16),
1628
GetColor(twocolor[0], 8),
1629
GetColor(twocolor[0], 0),
1630
GetColor(twocolor[1], 16),
1631
GetColor(twocolor[1], 8),
1632
GetColor(twocolor[1], 0),
1633
&pCursor, client, stuff->cid);
1636
if (!AddResource(stuff->cid, RT_CURSOR, (void *) pCursor)) {
1649
ProcRenderSetPictureTransform(ClientPtr client)
1651
REQUEST(xRenderSetPictureTransformReq);
1652
PicturePtr pPicture;
1654
REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
1655
VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
1656
return SetPictureTransform(pPicture, (PictTransform *) &stuff->transform);
1660
ProcRenderQueryFilters(ClientPtr client)
1662
REQUEST(xRenderQueryFiltersReq);
1663
DrawablePtr pDrawable;
1664
xRenderQueryFiltersReply *reply;
1668
PictureScreenPtr ps;
1669
int i, j, len, total_bytes, rc;
1673
REQUEST_SIZE_MATCH(xRenderQueryFiltersReq);
1674
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
1679
pScreen = pDrawable->pScreen;
1682
ps = GetPictureScreenIfSet(pScreen);
1684
for (i = 0; i < ps->nfilters; i++)
1685
nbytesName += 1 + strlen(ps->filters[i].name);
1686
for (i = 0; i < ps->nfilterAliases; i++)
1687
nbytesName += 1 + strlen(ps->filterAliases[i].alias);
1688
nnames = ps->nfilters + ps->nfilterAliases;
1690
len = ((nnames + 1) >> 1) + bytes_to_int32(nbytesName);
1691
total_bytes = sizeof(xRenderQueryFiltersReply) + (len << 2);
1692
reply = (xRenderQueryFiltersReply *) calloc(1, total_bytes);
1695
aliases = (INT16 *) (reply + 1);
1696
names = (char *) (aliases + ((nnames + 1) & ~1));
1698
reply->type = X_Reply;
1699
reply->sequenceNumber = client->sequence;
1700
reply->length = len;
1701
reply->numAliases = nnames;
1702
reply->numFilters = nnames;
1705
/* fill in alias values */
1706
for (i = 0; i < ps->nfilters; i++)
1707
aliases[i] = FilterAliasNone;
1708
for (i = 0; i < ps->nfilterAliases; i++) {
1709
for (j = 0; j < ps->nfilters; j++)
1710
if (ps->filterAliases[i].filter_id == ps->filters[j].id)
1712
if (j == ps->nfilters) {
1713
for (j = 0; j < ps->nfilterAliases; j++)
1714
if (ps->filterAliases[i].filter_id ==
1715
ps->filterAliases[j].alias_id) {
1718
if (j == ps->nfilterAliases)
1719
j = FilterAliasNone;
1721
j = j + ps->nfilters;
1723
aliases[i + ps->nfilters] = j;
1726
/* fill in filter names */
1727
for (i = 0; i < ps->nfilters; i++) {
1728
j = strlen(ps->filters[i].name);
1730
memcpy(names, ps->filters[i].name, j);
1734
/* fill in filter alias names */
1735
for (i = 0; i < ps->nfilterAliases; i++) {
1736
j = strlen(ps->filterAliases[i].alias);
1738
memcpy(names, ps->filterAliases[i].alias, j);
1743
if (client->swapped) {
1744
for (i = 0; i < reply->numAliases; i++) {
1747
swaps(&reply->sequenceNumber);
1748
swapl(&reply->length);
1749
swapl(&reply->numAliases);
1750
swapl(&reply->numFilters);
1752
WriteToClient(client, total_bytes, reply);
1759
ProcRenderSetPictureFilter(ClientPtr client)
1761
REQUEST(xRenderSetPictureFilterReq);
1762
PicturePtr pPicture;
1768
REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq);
1769
VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
1770
name = (char *) (stuff + 1);
1771
params = (xFixed *) (name + pad_to_int32(stuff->nbytes));
1772
nparams = ((xFixed *) stuff + client->req_len) - params;
1773
result = SetPictureFilter(pPicture, name, stuff->nbytes, params, nparams);
1778
ProcRenderCreateAnimCursor(ClientPtr client)
1780
REQUEST(xRenderCreateAnimCursorReq);
1785
xAnimCursorElt *elt;
1789
REQUEST_AT_LEAST_SIZE(xRenderCreateAnimCursorReq);
1790
LEGAL_NEW_RESOURCE(stuff->cid, client);
1791
if (client->req_len & 1)
1795
(bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1;
1796
cursors = xallocarray(ncursor, sizeof(CursorPtr) + sizeof(CARD32));
1799
deltas = (CARD32 *) (cursors + ncursor);
1800
elt = (xAnimCursorElt *) (stuff + 1);
1801
for (i = 0; i < ncursor; i++) {
1802
ret = dixLookupResourceByType((void **) (cursors + i), elt->cursor,
1803
RT_CURSOR, client, DixReadAccess);
1804
if (ret != Success) {
1808
deltas[i] = elt->delay;
1811
ret = AnimCursorCreate(cursors, deltas, ncursor, &pCursor, client,
1817
if (AddResource(stuff->cid, RT_CURSOR, (void *) pCursor))
1823
ProcRenderAddTraps(ClientPtr client)
1826
PicturePtr pPicture;
1828
REQUEST(xRenderAddTrapsReq);
1830
REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq);
1831
VERIFY_PICTURE(pPicture, stuff->picture, client, DixWriteAccess);
1832
if (!pPicture->pDrawable)
1834
ntraps = (client->req_len << 2) - sizeof(xRenderAddTrapsReq);
1835
if (ntraps % sizeof(xTrap))
1837
ntraps /= sizeof(xTrap);
1840
stuff->xOff, stuff->yOff, ntraps, (xTrap *) &stuff[1]);
1845
ProcRenderCreateSolidFill(ClientPtr client)
1847
PicturePtr pPicture;
1850
REQUEST(xRenderCreateSolidFillReq);
1852
REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq);
1854
LEGAL_NEW_RESOURCE(stuff->pid, client);
1856
pPicture = CreateSolidPicture(stuff->pid, &stuff->color, &error);
1859
/* security creation/labeling check */
1860
error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
1861
pPicture, RT_NONE, NULL, DixCreateAccess);
1862
if (error != Success)
1864
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
1870
ProcRenderCreateLinearGradient(ClientPtr client)
1872
PicturePtr pPicture;
1876
xRenderColor *colors;
1878
REQUEST(xRenderCreateLinearGradientReq);
1880
REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq);
1882
LEGAL_NEW_RESOURCE(stuff->pid, client);
1884
len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
1885
if (stuff->nStops > UINT32_MAX / (sizeof(xFixed) + sizeof(xRenderColor)))
1887
if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor)))
1890
stops = (xFixed *) (stuff + 1);
1891
colors = (xRenderColor *) (stops + stuff->nStops);
1893
pPicture = CreateLinearGradientPicture(stuff->pid, &stuff->p1, &stuff->p2,
1894
stuff->nStops, stops, colors,
1898
/* security creation/labeling check */
1899
error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
1900
pPicture, RT_NONE, NULL, DixCreateAccess);
1901
if (error != Success)
1903
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
1909
ProcRenderCreateRadialGradient(ClientPtr client)
1911
PicturePtr pPicture;
1915
xRenderColor *colors;
1917
REQUEST(xRenderCreateRadialGradientReq);
1919
REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq);
1921
LEGAL_NEW_RESOURCE(stuff->pid, client);
1923
len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq);
1924
if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor)))
1927
stops = (xFixed *) (stuff + 1);
1928
colors = (xRenderColor *) (stops + stuff->nStops);
1931
CreateRadialGradientPicture(stuff->pid, &stuff->inner, &stuff->outer,
1932
stuff->inner_radius, stuff->outer_radius,
1933
stuff->nStops, stops, colors, &error);
1936
/* security creation/labeling check */
1937
error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
1938
pPicture, RT_NONE, NULL, DixCreateAccess);
1939
if (error != Success)
1941
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
1947
ProcRenderCreateConicalGradient(ClientPtr client)
1949
PicturePtr pPicture;
1953
xRenderColor *colors;
1955
REQUEST(xRenderCreateConicalGradientReq);
1957
REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq);
1959
LEGAL_NEW_RESOURCE(stuff->pid, client);
1961
len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq);
1962
if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor)))
1965
stops = (xFixed *) (stuff + 1);
1966
colors = (xRenderColor *) (stops + stuff->nStops);
1969
CreateConicalGradientPicture(stuff->pid, &stuff->center, stuff->angle,
1970
stuff->nStops, stops, colors, &error);
1973
/* security creation/labeling check */
1974
error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
1975
pPicture, RT_NONE, NULL, DixCreateAccess);
1976
if (error != Success)
1978
if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
1984
ProcRenderDispatch(ClientPtr client)
1988
if (stuff->data < RenderNumberRequests)
1989
return (*ProcRenderVector[stuff->data]) (client);
1995
SProcRenderQueryVersion(ClientPtr client)
1997
REQUEST(xRenderQueryVersionReq);
1998
REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
1999
swaps(&stuff->length);
2000
swapl(&stuff->majorVersion);
2001
swapl(&stuff->minorVersion);
2002
return (*ProcRenderVector[stuff->renderReqType]) (client);
2006
SProcRenderQueryPictFormats(ClientPtr client)
2008
REQUEST(xRenderQueryPictFormatsReq);
2009
REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq);
2010
swaps(&stuff->length);
2011
return (*ProcRenderVector[stuff->renderReqType]) (client);
2015
SProcRenderQueryPictIndexValues(ClientPtr client)
2017
REQUEST(xRenderQueryPictIndexValuesReq);
2018
REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq);
2019
swaps(&stuff->length);
2020
swapl(&stuff->format);
2021
return (*ProcRenderVector[stuff->renderReqType]) (client);
2025
SProcRenderQueryDithers(ClientPtr client)
2027
return BadImplementation;
2031
SProcRenderCreatePicture(ClientPtr client)
2033
REQUEST(xRenderCreatePictureReq);
2034
REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
2035
swaps(&stuff->length);
2037
swapl(&stuff->drawable);
2038
swapl(&stuff->format);
2039
swapl(&stuff->mask);
2041
return (*ProcRenderVector[stuff->renderReqType]) (client);
2045
SProcRenderChangePicture(ClientPtr client)
2047
REQUEST(xRenderChangePictureReq);
2048
REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
2049
swaps(&stuff->length);
2050
swapl(&stuff->picture);
2051
swapl(&stuff->mask);
2053
return (*ProcRenderVector[stuff->renderReqType]) (client);
2057
SProcRenderSetPictureClipRectangles(ClientPtr client)
2059
REQUEST(xRenderSetPictureClipRectanglesReq);
2060
REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
2061
swaps(&stuff->length);
2062
swapl(&stuff->picture);
2063
swaps(&stuff->xOrigin);
2064
swaps(&stuff->yOrigin);
2066
return (*ProcRenderVector[stuff->renderReqType]) (client);
2070
SProcRenderFreePicture(ClientPtr client)
2072
REQUEST(xRenderFreePictureReq);
2073
REQUEST_SIZE_MATCH(xRenderFreePictureReq);
2074
swaps(&stuff->length);
2075
swapl(&stuff->picture);
2076
return (*ProcRenderVector[stuff->renderReqType]) (client);
2080
SProcRenderComposite(ClientPtr client)
2082
REQUEST(xRenderCompositeReq);
2083
REQUEST_SIZE_MATCH(xRenderCompositeReq);
2084
swaps(&stuff->length);
2086
swapl(&stuff->mask);
2088
swaps(&stuff->xSrc);
2089
swaps(&stuff->ySrc);
2090
swaps(&stuff->xMask);
2091
swaps(&stuff->yMask);
2092
swaps(&stuff->xDst);
2093
swaps(&stuff->yDst);
2094
swaps(&stuff->width);
2095
swaps(&stuff->height);
2096
return (*ProcRenderVector[stuff->renderReqType]) (client);
2100
SProcRenderScale(ClientPtr client)
2102
return BadImplementation;
2106
SProcRenderTrapezoids(ClientPtr client)
2108
REQUEST(xRenderTrapezoidsReq);
2110
REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq);
2111
swaps(&stuff->length);
2114
swapl(&stuff->maskFormat);
2115
swaps(&stuff->xSrc);
2116
swaps(&stuff->ySrc);
2118
return (*ProcRenderVector[stuff->renderReqType]) (client);
2122
SProcRenderTriangles(ClientPtr client)
2124
REQUEST(xRenderTrianglesReq);
2126
REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
2127
swaps(&stuff->length);
2130
swapl(&stuff->maskFormat);
2131
swaps(&stuff->xSrc);
2132
swaps(&stuff->ySrc);
2134
return (*ProcRenderVector[stuff->renderReqType]) (client);
2138
SProcRenderTriStrip(ClientPtr client)
2140
REQUEST(xRenderTriStripReq);
2142
REQUEST_AT_LEAST_SIZE(xRenderTriStripReq);
2143
swaps(&stuff->length);
2146
swapl(&stuff->maskFormat);
2147
swaps(&stuff->xSrc);
2148
swaps(&stuff->ySrc);
2150
return (*ProcRenderVector[stuff->renderReqType]) (client);
2154
SProcRenderTriFan(ClientPtr client)
2156
REQUEST(xRenderTriFanReq);
2158
REQUEST_AT_LEAST_SIZE(xRenderTriFanReq);
2159
swaps(&stuff->length);
2162
swapl(&stuff->maskFormat);
2163
swaps(&stuff->xSrc);
2164
swaps(&stuff->ySrc);
2166
return (*ProcRenderVector[stuff->renderReqType]) (client);
2170
SProcRenderColorTrapezoids(ClientPtr client)
2172
return BadImplementation;
2176
SProcRenderColorTriangles(ClientPtr client)
2178
return BadImplementation;
2182
SProcRenderTransform(ClientPtr client)
2184
return BadImplementation;
2188
SProcRenderCreateGlyphSet(ClientPtr client)
2190
REQUEST(xRenderCreateGlyphSetReq);
2191
REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
2192
swaps(&stuff->length);
2193
swapl(&stuff->gsid);
2194
swapl(&stuff->format);
2195
return (*ProcRenderVector[stuff->renderReqType]) (client);
2199
SProcRenderReferenceGlyphSet(ClientPtr client)
2201
REQUEST(xRenderReferenceGlyphSetReq);
2202
REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq);
2203
swaps(&stuff->length);
2204
swapl(&stuff->gsid);
2205
swapl(&stuff->existing);
2206
return (*ProcRenderVector[stuff->renderReqType]) (client);
2210
SProcRenderFreeGlyphSet(ClientPtr client)
2212
REQUEST(xRenderFreeGlyphSetReq);
2213
REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
2214
swaps(&stuff->length);
2215
swapl(&stuff->glyphset);
2216
return (*ProcRenderVector[stuff->renderReqType]) (client);
2220
SProcRenderAddGlyphs(ClientPtr client)
2227
REQUEST(xRenderAddGlyphsReq);
2228
REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
2229
swaps(&stuff->length);
2230
swapl(&stuff->glyphset);
2231
swapl(&stuff->nglyphs);
2232
if (stuff->nglyphs & 0xe0000000)
2234
end = (CARD8 *) stuff + (client->req_len << 2);
2235
gids = (CARD32 *) (stuff + 1);
2236
gi = (xGlyphInfo *) (gids + stuff->nglyphs);
2237
if ((char *) end - (char *) (gids + stuff->nglyphs) < 0)
2239
if ((char *) end - (char *) (gi + stuff->nglyphs) < 0)
2241
for (i = 0; i < stuff->nglyphs; i++) {
2243
swaps(&gi[i].width);
2244
swaps(&gi[i].height);
2250
return (*ProcRenderVector[stuff->renderReqType]) (client);
2254
SProcRenderAddGlyphsFromPicture(ClientPtr client)
2256
return BadImplementation;
2260
SProcRenderFreeGlyphs(ClientPtr client)
2262
REQUEST(xRenderFreeGlyphsReq);
2263
REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
2264
swaps(&stuff->length);
2265
swapl(&stuff->glyphset);
2267
return (*ProcRenderVector[stuff->renderReqType]) (client);
2271
SProcRenderCompositeGlyphs(ClientPtr client)
2280
REQUEST(xRenderCompositeGlyphsReq);
2281
REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);
2283
switch (stuff->renderReqType) {
2287
case X_RenderCompositeGlyphs16:
2290
case X_RenderCompositeGlyphs32:
2295
swaps(&stuff->length);
2298
swapl(&stuff->maskFormat);
2299
swapl(&stuff->glyphset);
2300
swaps(&stuff->xSrc);
2301
swaps(&stuff->ySrc);
2302
buffer = (CARD8 *) (stuff + 1);
2303
end = (CARD8 *) stuff + (client->req_len << 2);
2304
while (buffer + sizeof(xGlyphElt) < end) {
2305
elt = (xGlyphElt *) buffer;
2306
buffer += sizeof(xGlyphElt);
2308
swaps(&elt->deltax);
2309
swaps(&elt->deltay);
2313
swapl((int *) buffer);
2324
swaps((short *) buffer);
2330
swapl((int *) buffer);
2336
buffer += 4 - (space & 3);
2339
return (*ProcRenderVector[stuff->renderReqType]) (client);
2343
SProcRenderFillRectangles(ClientPtr client)
2345
REQUEST(xRenderFillRectanglesReq);
2347
REQUEST_AT_LEAST_SIZE(xRenderFillRectanglesReq);
2348
swaps(&stuff->length);
2350
swaps(&stuff->color.red);
2351
swaps(&stuff->color.green);
2352
swaps(&stuff->color.blue);
2353
swaps(&stuff->color.alpha);
2355
return (*ProcRenderVector[stuff->renderReqType]) (client);
2359
SProcRenderCreateCursor(ClientPtr client)
2361
REQUEST(xRenderCreateCursorReq);
2362
REQUEST_SIZE_MATCH(xRenderCreateCursorReq);
2364
swaps(&stuff->length);
2369
return (*ProcRenderVector[stuff->renderReqType]) (client);
2373
SProcRenderSetPictureTransform(ClientPtr client)
2375
REQUEST(xRenderSetPictureTransformReq);
2376
REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
2378
swaps(&stuff->length);
2379
swapl(&stuff->picture);
2380
swapl(&stuff->transform.matrix11);
2381
swapl(&stuff->transform.matrix12);
2382
swapl(&stuff->transform.matrix13);
2383
swapl(&stuff->transform.matrix21);
2384
swapl(&stuff->transform.matrix22);
2385
swapl(&stuff->transform.matrix23);
2386
swapl(&stuff->transform.matrix31);
2387
swapl(&stuff->transform.matrix32);
2388
swapl(&stuff->transform.matrix33);
2389
return (*ProcRenderVector[stuff->renderReqType]) (client);
2393
SProcRenderQueryFilters(ClientPtr client)
2395
REQUEST(xRenderQueryFiltersReq);
2396
REQUEST_SIZE_MATCH(xRenderQueryFiltersReq);
2398
swaps(&stuff->length);
2399
swapl(&stuff->drawable);
2400
return (*ProcRenderVector[stuff->renderReqType]) (client);
2404
SProcRenderSetPictureFilter(ClientPtr client)
2406
REQUEST(xRenderSetPictureFilterReq);
2407
REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq);
2409
swaps(&stuff->length);
2410
swapl(&stuff->picture);
2411
swaps(&stuff->nbytes);
2412
return (*ProcRenderVector[stuff->renderReqType]) (client);
2416
SProcRenderCreateAnimCursor(ClientPtr client)
2418
REQUEST(xRenderCreateAnimCursorReq);
2419
REQUEST_AT_LEAST_SIZE(xRenderCreateAnimCursorReq);
2421
swaps(&stuff->length);
2424
return (*ProcRenderVector[stuff->renderReqType]) (client);
2428
SProcRenderAddTraps(ClientPtr client)
2430
REQUEST(xRenderAddTrapsReq);
2431
REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq);
2433
swaps(&stuff->length);
2434
swapl(&stuff->picture);
2435
swaps(&stuff->xOff);
2436
swaps(&stuff->yOff);
2438
return (*ProcRenderVector[stuff->renderReqType]) (client);
2442
SProcRenderCreateSolidFill(ClientPtr client)
2444
REQUEST(xRenderCreateSolidFillReq);
2445
REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq);
2447
swaps(&stuff->length);
2449
swaps(&stuff->color.alpha);
2450
swaps(&stuff->color.red);
2451
swaps(&stuff->color.green);
2452
swaps(&stuff->color.blue);
2453
return (*ProcRenderVector[stuff->renderReqType]) (client);
2457
swapStops(void *stuff, int num)
2463
stops = (CARD32 *) (stuff);
2464
for (i = 0; i < num; ++i) {
2468
colors = (CARD16 *) (stops);
2469
for (i = 0; i < 4 * num; ++i) {
2476
SProcRenderCreateLinearGradient(ClientPtr client)
2480
REQUEST(xRenderCreateLinearGradientReq);
2481
REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq);
2483
swaps(&stuff->length);
2485
swapl(&stuff->p1.x);
2486
swapl(&stuff->p1.y);
2487
swapl(&stuff->p2.x);
2488
swapl(&stuff->p2.y);
2489
swapl(&stuff->nStops);
2491
len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
2492
if (stuff->nStops > UINT32_MAX / (sizeof(xFixed) + sizeof(xRenderColor)))
2494
if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor)))
2497
swapStops(stuff + 1, stuff->nStops);
2499
return (*ProcRenderVector[stuff->renderReqType]) (client);
2503
SProcRenderCreateRadialGradient(ClientPtr client)
2507
REQUEST(xRenderCreateRadialGradientReq);
2508
REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq);
2510
swaps(&stuff->length);
2512
swapl(&stuff->inner.x);
2513
swapl(&stuff->inner.y);
2514
swapl(&stuff->outer.x);
2515
swapl(&stuff->outer.y);
2516
swapl(&stuff->inner_radius);
2517
swapl(&stuff->outer_radius);
2518
swapl(&stuff->nStops);
2520
len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq);
2521
if (stuff->nStops > UINT32_MAX / (sizeof(xFixed) + sizeof(xRenderColor)))
2523
if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor)))
2526
swapStops(stuff + 1, stuff->nStops);
2528
return (*ProcRenderVector[stuff->renderReqType]) (client);
2532
SProcRenderCreateConicalGradient(ClientPtr client)
2536
REQUEST(xRenderCreateConicalGradientReq);
2537
REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq);
2539
swaps(&stuff->length);
2541
swapl(&stuff->center.x);
2542
swapl(&stuff->center.y);
2543
swapl(&stuff->angle);
2544
swapl(&stuff->nStops);
2546
len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq);
2547
if (stuff->nStops > UINT32_MAX / (sizeof(xFixed) + sizeof(xRenderColor)))
2549
if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor)))
2552
swapStops(stuff + 1, stuff->nStops);
2554
return (*ProcRenderVector[stuff->renderReqType]) (client);
2558
SProcRenderDispatch(ClientPtr client)
2562
if (stuff->data < RenderNumberRequests)
2563
return (*SProcRenderVector[stuff->data]) (client);
2569
#define VERIFY_XIN_PICTURE(pPicture, pid, client, mode) {\
2570
int rc = dixLookupResourceByType((void **)&(pPicture), pid,\
2571
XRT_PICTURE, client, mode);\
2576
#define VERIFY_XIN_ALPHA(pPicture, pid, client, mode) {\
2580
VERIFY_XIN_PICTURE(pPicture, pid, client, mode); \
2584
int (*PanoramiXSaveRenderVector[RenderNumberRequests]) (ClientPtr);
2587
PanoramiXRenderCreatePicture(ClientPtr client)
2589
REQUEST(xRenderCreatePictureReq);
2590
PanoramiXRes *refDraw, *newPict;
2593
REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
2594
result = dixLookupResourceByClass((void **) &refDraw, stuff->drawable,
2595
XRC_DRAWABLE, client, DixWriteAccess);
2596
if (result != Success)
2597
return (result == BadValue) ? BadDrawable : result;
2598
if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
2600
newPict->type = XRT_PICTURE;
2601
panoramix_setup_ids(newPict, client, stuff->pid);
2603
if (refDraw->type == XRT_WINDOW &&
2604
stuff->drawable == screenInfo.screens[0]->root->drawable.id) {
2605
newPict->u.pict.root = TRUE;
2608
newPict->u.pict.root = FALSE;
2610
FOR_NSCREENS_BACKWARD(j) {
2611
stuff->pid = newPict->info[j].id;
2612
stuff->drawable = refDraw->info[j].id;
2613
result = (*PanoramiXSaveRenderVector[X_RenderCreatePicture]) (client);
2614
if (result != Success)
2618
if (result == Success)
2619
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
2627
PanoramiXRenderChangePicture(ClientPtr client)
2630
int result = Success, j;
2632
REQUEST(xRenderChangePictureReq);
2634
REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
2636
VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess);
2638
FOR_NSCREENS_BACKWARD(j) {
2639
stuff->picture = pict->info[j].id;
2640
result = (*PanoramiXSaveRenderVector[X_RenderChangePicture]) (client);
2641
if (result != Success)
2649
PanoramiXRenderSetPictureClipRectangles(ClientPtr client)
2651
REQUEST(xRenderSetPictureClipRectanglesReq);
2652
int result = Success, j;
2655
REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
2657
VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess);
2659
FOR_NSCREENS_BACKWARD(j) {
2660
stuff->picture = pict->info[j].id;
2662
(*PanoramiXSaveRenderVector[X_RenderSetPictureClipRectangles])
2664
if (result != Success)
2672
PanoramiXRenderSetPictureTransform(ClientPtr client)
2674
REQUEST(xRenderSetPictureTransformReq);
2675
int result = Success, j;
2678
REQUEST_AT_LEAST_SIZE(xRenderSetPictureTransformReq);
2680
VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess);
2682
FOR_NSCREENS_BACKWARD(j) {
2683
stuff->picture = pict->info[j].id;
2685
(*PanoramiXSaveRenderVector[X_RenderSetPictureTransform]) (client);
2686
if (result != Success)
2694
PanoramiXRenderSetPictureFilter(ClientPtr client)
2696
REQUEST(xRenderSetPictureFilterReq);
2697
int result = Success, j;
2700
REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq);
2702
VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess);
2704
FOR_NSCREENS_BACKWARD(j) {
2705
stuff->picture = pict->info[j].id;
2707
(*PanoramiXSaveRenderVector[X_RenderSetPictureFilter]) (client);
2708
if (result != Success)
2716
PanoramiXRenderFreePicture(ClientPtr client)
2719
int result = Success, j;
2721
REQUEST(xRenderFreePictureReq);
2723
REQUEST_SIZE_MATCH(xRenderFreePictureReq);
2725
client->errorValue = stuff->picture;
2727
VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixDestroyAccess);
2729
FOR_NSCREENS_BACKWARD(j) {
2730
stuff->picture = pict->info[j].id;
2731
result = (*PanoramiXSaveRenderVector[X_RenderFreePicture]) (client);
2732
if (result != Success)
2736
/* Since ProcRenderFreePicture is using FreeResource, it will free
2737
our resource for us on the last pass through the loop above */
2743
PanoramiXRenderComposite(ClientPtr client)
2745
PanoramiXRes *src, *msk, *dst;
2746
int result = Success, j;
2747
xRenderCompositeReq orig;
2749
REQUEST(xRenderCompositeReq);
2751
REQUEST_SIZE_MATCH(xRenderCompositeReq);
2753
VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess);
2754
VERIFY_XIN_ALPHA(msk, stuff->mask, client, DixReadAccess);
2755
VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess);
2759
FOR_NSCREENS_FORWARD(j) {
2760
stuff->src = src->info[j].id;
2761
if (src->u.pict.root) {
2762
stuff->xSrc = orig.xSrc - screenInfo.screens[j]->x;
2763
stuff->ySrc = orig.ySrc - screenInfo.screens[j]->y;
2765
stuff->dst = dst->info[j].id;
2766
if (dst->u.pict.root) {
2767
stuff->xDst = orig.xDst - screenInfo.screens[j]->x;
2768
stuff->yDst = orig.yDst - screenInfo.screens[j]->y;
2771
stuff->mask = msk->info[j].id;
2772
if (msk->u.pict.root) {
2773
stuff->xMask = orig.xMask - screenInfo.screens[j]->x;
2774
stuff->yMask = orig.yMask - screenInfo.screens[j]->y;
2777
result = (*PanoramiXSaveRenderVector[X_RenderComposite]) (client);
2778
if (result != Success)
2786
PanoramiXRenderCompositeGlyphs(ClientPtr client)
2788
PanoramiXRes *src, *dst;
2789
int result = Success, j;
2791
REQUEST(xRenderCompositeGlyphsReq);
2792
xGlyphElt origElt, *elt;
2795
REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);
2796
VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess);
2797
VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess);
2799
if (client->req_len << 2 >= (sizeof(xRenderCompositeGlyphsReq) +
2800
sizeof(xGlyphElt))) {
2801
elt = (xGlyphElt *) (stuff + 1);
2805
FOR_NSCREENS_FORWARD(j) {
2806
stuff->src = src->info[j].id;
2807
if (src->u.pict.root) {
2808
stuff->xSrc = xSrc - screenInfo.screens[j]->x;
2809
stuff->ySrc = ySrc - screenInfo.screens[j]->y;
2811
stuff->dst = dst->info[j].id;
2812
if (dst->u.pict.root) {
2813
elt->deltax = origElt.deltax - screenInfo.screens[j]->x;
2814
elt->deltay = origElt.deltay - screenInfo.screens[j]->y;
2817
(*PanoramiXSaveRenderVector[stuff->renderReqType]) (client);
2818
if (result != Success)
2827
PanoramiXRenderFillRectangles(ClientPtr client)
2830
int result = Success, j;
2832
REQUEST(xRenderFillRectanglesReq);
2836
REQUEST_AT_LEAST_SIZE(xRenderFillRectanglesReq);
2837
VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess);
2838
extra_len = (client->req_len << 2) - sizeof(xRenderFillRectanglesReq);
2839
if (extra_len && (extra = (char *) malloc(extra_len))) {
2840
memcpy(extra, stuff + 1, extra_len);
2841
FOR_NSCREENS_FORWARD(j) {
2843
memcpy(stuff + 1, extra, extra_len);
2844
if (dst->u.pict.root) {
2845
int x_off = screenInfo.screens[j]->x;
2846
int y_off = screenInfo.screens[j]->y;
2848
if (x_off || y_off) {
2849
xRectangle *rects = (xRectangle *) (stuff + 1);
2850
int i = extra_len / sizeof(xRectangle);
2859
stuff->dst = dst->info[j].id;
2861
(*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client);
2862
if (result != Success)
2872
PanoramiXRenderTrapezoids(ClientPtr client)
2874
PanoramiXRes *src, *dst;
2875
int result = Success, j;
2877
REQUEST(xRenderTrapezoidsReq);
2881
REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq);
2883
VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess);
2884
VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess);
2886
extra_len = (client->req_len << 2) - sizeof(xRenderTrapezoidsReq);
2888
if (extra_len && (extra = (char *) malloc(extra_len))) {
2889
memcpy(extra, stuff + 1, extra_len);
2891
FOR_NSCREENS_FORWARD(j) {
2893
memcpy(stuff + 1, extra, extra_len);
2894
if (dst->u.pict.root) {
2895
int x_off = screenInfo.screens[j]->x;
2896
int y_off = screenInfo.screens[j]->y;
2898
if (x_off || y_off) {
2899
xTrapezoid *trap = (xTrapezoid *) (stuff + 1);
2900
int i = extra_len / sizeof(xTrapezoid);
2904
trap->bottom -= y_off;
2905
trap->left.p1.x -= x_off;
2906
trap->left.p1.y -= y_off;
2907
trap->left.p2.x -= x_off;
2908
trap->left.p2.y -= y_off;
2909
trap->right.p1.x -= x_off;
2910
trap->right.p1.y -= y_off;
2911
trap->right.p2.x -= x_off;
2912
trap->right.p2.y -= y_off;
2918
stuff->src = src->info[j].id;
2919
stuff->dst = dst->info[j].id;
2920
result = (*PanoramiXSaveRenderVector[X_RenderTrapezoids]) (client);
2922
if (result != Success)
2933
PanoramiXRenderTriangles(ClientPtr client)
2935
PanoramiXRes *src, *dst;
2936
int result = Success, j;
2938
REQUEST(xRenderTrianglesReq);
2942
REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
2944
VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess);
2945
VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess);
2947
extra_len = (client->req_len << 2) - sizeof(xRenderTrianglesReq);
2949
if (extra_len && (extra = (char *) malloc(extra_len))) {
2950
memcpy(extra, stuff + 1, extra_len);
2952
FOR_NSCREENS_FORWARD(j) {
2954
memcpy(stuff + 1, extra, extra_len);
2955
if (dst->u.pict.root) {
2956
int x_off = screenInfo.screens[j]->x;
2957
int y_off = screenInfo.screens[j]->y;
2959
if (x_off || y_off) {
2960
xTriangle *tri = (xTriangle *) (stuff + 1);
2961
int i = extra_len / sizeof(xTriangle);
2975
stuff->src = src->info[j].id;
2976
stuff->dst = dst->info[j].id;
2977
result = (*PanoramiXSaveRenderVector[X_RenderTriangles]) (client);
2979
if (result != Success)
2990
PanoramiXRenderTriStrip(ClientPtr client)
2992
PanoramiXRes *src, *dst;
2993
int result = Success, j;
2995
REQUEST(xRenderTriStripReq);
2999
REQUEST_AT_LEAST_SIZE(xRenderTriStripReq);
3001
VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess);
3002
VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess);
3004
extra_len = (client->req_len << 2) - sizeof(xRenderTriStripReq);
3006
if (extra_len && (extra = (char *) malloc(extra_len))) {
3007
memcpy(extra, stuff + 1, extra_len);
3009
FOR_NSCREENS_FORWARD(j) {
3011
memcpy(stuff + 1, extra, extra_len);
3012
if (dst->u.pict.root) {
3013
int x_off = screenInfo.screens[j]->x;
3014
int y_off = screenInfo.screens[j]->y;
3016
if (x_off || y_off) {
3017
xPointFixed *fixed = (xPointFixed *) (stuff + 1);
3018
int i = extra_len / sizeof(xPointFixed);
3028
stuff->src = src->info[j].id;
3029
stuff->dst = dst->info[j].id;
3030
result = (*PanoramiXSaveRenderVector[X_RenderTriStrip]) (client);
3032
if (result != Success)
3043
PanoramiXRenderTriFan(ClientPtr client)
3045
PanoramiXRes *src, *dst;
3046
int result = Success, j;
3048
REQUEST(xRenderTriFanReq);
3052
REQUEST_AT_LEAST_SIZE(xRenderTriFanReq);
3054
VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess);
3055
VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess);
3057
extra_len = (client->req_len << 2) - sizeof(xRenderTriFanReq);
3059
if (extra_len && (extra = (char *) malloc(extra_len))) {
3060
memcpy(extra, stuff + 1, extra_len);
3062
FOR_NSCREENS_FORWARD(j) {
3064
memcpy(stuff + 1, extra, extra_len);
3065
if (dst->u.pict.root) {
3066
int x_off = screenInfo.screens[j]->x;
3067
int y_off = screenInfo.screens[j]->y;
3069
if (x_off || y_off) {
3070
xPointFixed *fixed = (xPointFixed *) (stuff + 1);
3071
int i = extra_len / sizeof(xPointFixed);
3081
stuff->src = src->info[j].id;
3082
stuff->dst = dst->info[j].id;
3083
result = (*PanoramiXSaveRenderVector[X_RenderTriFan]) (client);
3085
if (result != Success)
3096
PanoramiXRenderAddTraps(ClientPtr client)
3098
PanoramiXRes *picture;
3099
int result = Success, j;
3101
REQUEST(xRenderAddTrapsReq);
3106
REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq);
3107
VERIFY_XIN_PICTURE(picture, stuff->picture, client, DixWriteAccess);
3108
extra_len = (client->req_len << 2) - sizeof(xRenderAddTrapsReq);
3109
if (extra_len && (extra = (char *) malloc(extra_len))) {
3110
memcpy(extra, stuff + 1, extra_len);
3111
x_off = stuff->xOff;
3112
y_off = stuff->yOff;
3113
FOR_NSCREENS_FORWARD(j) {
3115
memcpy(stuff + 1, extra, extra_len);
3116
stuff->picture = picture->info[j].id;
3118
if (picture->u.pict.root) {
3119
stuff->xOff = x_off + screenInfo.screens[j]->x;
3120
stuff->yOff = y_off + screenInfo.screens[j]->y;
3122
result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client);
3123
if (result != Success)
3133
PanoramiXRenderCreateSolidFill(ClientPtr client)
3135
REQUEST(xRenderCreateSolidFillReq);
3136
PanoramiXRes *newPict;
3137
int result = Success, j;
3139
REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq);
3141
if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
3144
newPict->type = XRT_PICTURE;
3145
panoramix_setup_ids(newPict, client, stuff->pid);
3146
newPict->u.pict.root = FALSE;
3148
FOR_NSCREENS_BACKWARD(j) {
3149
stuff->pid = newPict->info[j].id;
3150
result = (*PanoramiXSaveRenderVector[X_RenderCreateSolidFill]) (client);
3151
if (result != Success)
3155
if (result == Success)
3156
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
3164
PanoramiXRenderCreateLinearGradient(ClientPtr client)
3166
REQUEST(xRenderCreateLinearGradientReq);
3167
PanoramiXRes *newPict;
3168
int result = Success, j;
3170
REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq);
3172
if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
3175
newPict->type = XRT_PICTURE;
3176
panoramix_setup_ids(newPict, client, stuff->pid);
3177
newPict->u.pict.root = FALSE;
3179
FOR_NSCREENS_BACKWARD(j) {
3180
stuff->pid = newPict->info[j].id;
3182
(*PanoramiXSaveRenderVector[X_RenderCreateLinearGradient]) (client);
3183
if (result != Success)
3187
if (result == Success)
3188
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
3196
PanoramiXRenderCreateRadialGradient(ClientPtr client)
3198
REQUEST(xRenderCreateRadialGradientReq);
3199
PanoramiXRes *newPict;
3200
int result = Success, j;
3202
REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq);
3204
if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
3207
newPict->type = XRT_PICTURE;
3208
panoramix_setup_ids(newPict, client, stuff->pid);
3209
newPict->u.pict.root = FALSE;
3211
FOR_NSCREENS_BACKWARD(j) {
3212
stuff->pid = newPict->info[j].id;
3214
(*PanoramiXSaveRenderVector[X_RenderCreateRadialGradient]) (client);
3215
if (result != Success)
3219
if (result == Success)
3220
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
3228
PanoramiXRenderCreateConicalGradient(ClientPtr client)
3230
REQUEST(xRenderCreateConicalGradientReq);
3231
PanoramiXRes *newPict;
3232
int result = Success, j;
3234
REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq);
3236
if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
3239
newPict->type = XRT_PICTURE;
3240
panoramix_setup_ids(newPict, client, stuff->pid);
3241
newPict->u.pict.root = FALSE;
3243
FOR_NSCREENS_BACKWARD(j) {
3244
stuff->pid = newPict->info[j].id;
3246
(*PanoramiXSaveRenderVector[X_RenderCreateConicalGradient])
3248
if (result != Success)
3252
if (result == Success)
3253
AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
3261
PanoramiXRenderInit(void)
3265
XRT_PICTURE = CreateNewResourceType(XineramaDeleteResource,
3268
SetResourceTypeErrorValue(XRT_PICTURE, RenderErrBase + BadPicture);
3269
for (i = 0; i < RenderNumberRequests; i++)
3270
PanoramiXSaveRenderVector[i] = ProcRenderVector[i];
3272
* Stuff in Xinerama aware request processing hooks
3274
ProcRenderVector[X_RenderCreatePicture] = PanoramiXRenderCreatePicture;
3275
ProcRenderVector[X_RenderChangePicture] = PanoramiXRenderChangePicture;
3276
ProcRenderVector[X_RenderSetPictureTransform] =
3277
PanoramiXRenderSetPictureTransform;
3278
ProcRenderVector[X_RenderSetPictureFilter] =
3279
PanoramiXRenderSetPictureFilter;
3280
ProcRenderVector[X_RenderSetPictureClipRectangles] =
3281
PanoramiXRenderSetPictureClipRectangles;
3282
ProcRenderVector[X_RenderFreePicture] = PanoramiXRenderFreePicture;
3283
ProcRenderVector[X_RenderComposite] = PanoramiXRenderComposite;
3284
ProcRenderVector[X_RenderCompositeGlyphs8] = PanoramiXRenderCompositeGlyphs;
3285
ProcRenderVector[X_RenderCompositeGlyphs16] =
3286
PanoramiXRenderCompositeGlyphs;
3287
ProcRenderVector[X_RenderCompositeGlyphs32] =
3288
PanoramiXRenderCompositeGlyphs;
3289
ProcRenderVector[X_RenderFillRectangles] = PanoramiXRenderFillRectangles;
3291
ProcRenderVector[X_RenderTrapezoids] = PanoramiXRenderTrapezoids;
3292
ProcRenderVector[X_RenderTriangles] = PanoramiXRenderTriangles;
3293
ProcRenderVector[X_RenderTriStrip] = PanoramiXRenderTriStrip;
3294
ProcRenderVector[X_RenderTriFan] = PanoramiXRenderTriFan;
3295
ProcRenderVector[X_RenderAddTraps] = PanoramiXRenderAddTraps;
3297
ProcRenderVector[X_RenderCreateSolidFill] = PanoramiXRenderCreateSolidFill;
3298
ProcRenderVector[X_RenderCreateLinearGradient] =
3299
PanoramiXRenderCreateLinearGradient;
3300
ProcRenderVector[X_RenderCreateRadialGradient] =
3301
PanoramiXRenderCreateRadialGradient;
3302
ProcRenderVector[X_RenderCreateConicalGradient] =
3303
PanoramiXRenderCreateConicalGradient;
3307
PanoramiXRenderReset(void)
3311
for (i = 0; i < RenderNumberRequests; i++)
3312
ProcRenderVector[i] = PanoramiXSaveRenderVector[i];
3316
#endif /* PANORAMIX */