~ubuntu-branches/ubuntu/trusty/xorg-server-lts-xenial/trusty-updates

« back to all changes in this revision

Viewing changes to render/render.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2016-05-03 14:02:21 UTC
  • Revision ID: package-import@ubuntu.com-20160503140221-722b5oen8it4o8h1
Tags: upstream-1.18.3
ImportĀ upstreamĀ versionĀ 1.18.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 * Copyright Ā© 2000 SuSE, Inc.
 
4
 *
 
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.
 
14
 *
 
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.
 
21
 *
 
22
 * Author:  Keith Packard, SuSE, Inc.
 
23
 */
 
24
 
 
25
#ifdef HAVE_DIX_CONFIG_H
 
26
#include <dix-config.h>
 
27
#endif
 
28
 
 
29
#include <X11/X.h>
 
30
#include <X11/Xproto.h>
 
31
#include "misc.h"
 
32
#include "os.h"
 
33
#include "dixstruct.h"
 
34
#include "resource.h"
 
35
#include "scrnintstr.h"
 
36
#include "windowstr.h"
 
37
#include "pixmapstr.h"
 
38
#include "colormapst.h"
 
39
#include "extnsionst.h"
 
40
#include "extinit.h"
 
41
#include "servermd.h"
 
42
#include <X11/extensions/render.h>
 
43
#include <X11/extensions/renderproto.h>
 
44
#include "picturestr.h"
 
45
#include "glyphstr.h"
 
46
#include <X11/Xfuncproto.h>
 
47
#include "cursorstr.h"
 
48
#include "xace.h"
 
49
#include "protocol-versions.h"
 
50
 
 
51
#ifdef PANORAMIX
 
52
#include "panoramiX.h"
 
53
#include "panoramiXsrv.h"
 
54
#endif
 
55
 
 
56
#include <stdint.h>
 
57
 
 
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);
 
93
 
 
94
static int ProcRenderDispatch(ClientPtr pClient);
 
95
 
 
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);
 
131
 
 
132
static int SProcRenderDispatch(ClientPtr pClient);
 
133
 
 
134
int (*ProcRenderVector[RenderNumberRequests]) (ClientPtr) = {
 
135
ProcRenderQueryVersion,
 
136
        ProcRenderQueryPictFormats,
 
137
        ProcRenderQueryPictIndexValues,
 
138
        ProcRenderQueryDithers,
 
139
        ProcRenderCreatePicture,
 
140
        ProcRenderChangePicture,
 
141
        ProcRenderSetPictureClipRectangles,
 
142
        ProcRenderFreePicture,
 
143
        ProcRenderComposite,
 
144
        ProcRenderScale,
 
145
        ProcRenderTrapezoids,
 
146
        ProcRenderTriangles,
 
147
        ProcRenderTriStrip,
 
148
        ProcRenderTriFan,
 
149
        ProcRenderColorTrapezoids,
 
150
        ProcRenderColorTriangles,
 
151
        ProcRenderTransform,
 
152
        ProcRenderCreateGlyphSet,
 
153
        ProcRenderReferenceGlyphSet,
 
154
        ProcRenderFreeGlyphSet,
 
155
        ProcRenderAddGlyphs,
 
156
        ProcRenderAddGlyphsFromPicture,
 
157
        ProcRenderFreeGlyphs,
 
158
        ProcRenderCompositeGlyphs,
 
159
        ProcRenderCompositeGlyphs,
 
160
        ProcRenderCompositeGlyphs,
 
161
        ProcRenderFillRectangles,
 
162
        ProcRenderCreateCursor,
 
163
        ProcRenderSetPictureTransform,
 
164
        ProcRenderQueryFilters,
 
165
        ProcRenderSetPictureFilter,
 
166
        ProcRenderCreateAnimCursor,
 
167
        ProcRenderAddTraps,
 
168
        ProcRenderCreateSolidFill,
 
169
        ProcRenderCreateLinearGradient,
 
170
        ProcRenderCreateRadialGradient, ProcRenderCreateConicalGradient};
 
171
 
 
172
int (*SProcRenderVector[RenderNumberRequests]) (ClientPtr) = {
 
173
SProcRenderQueryVersion,
 
174
        SProcRenderQueryPictFormats,
 
175
        SProcRenderQueryPictIndexValues,
 
176
        SProcRenderQueryDithers,
 
177
        SProcRenderCreatePicture,
 
178
        SProcRenderChangePicture,
 
179
        SProcRenderSetPictureClipRectangles,
 
180
        SProcRenderFreePicture,
 
181
        SProcRenderComposite,
 
182
        SProcRenderScale,
 
183
        SProcRenderTrapezoids,
 
184
        SProcRenderTriangles,
 
185
        SProcRenderTriStrip,
 
186
        SProcRenderTriFan,
 
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,
 
205
        SProcRenderAddTraps,
 
206
        SProcRenderCreateSolidFill,
 
207
        SProcRenderCreateLinearGradient,
 
208
        SProcRenderCreateRadialGradient, SProcRenderCreateConicalGradient};
 
209
 
 
210
int RenderErrBase;
 
211
static DevPrivateKeyRec RenderClientPrivateKeyRec;
 
212
 
 
213
#define RenderClientPrivateKey (&RenderClientPrivateKeyRec )
 
214
 
 
215
typedef struct _RenderClient {
 
216
    int major_version;
 
217
    int minor_version;
 
218
} RenderClientRec, *RenderClientPtr;
 
219
 
 
220
#define GetRenderClient(pClient) ((RenderClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RenderClientPrivateKey))
 
221
 
 
222
static void
 
223
RenderClientCallback(CallbackListPtr *list, void *closure, void *data)
 
224
{
 
225
    NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
 
226
    ClientPtr pClient = clientinfo->client;
 
227
    RenderClientPtr pRenderClient = GetRenderClient(pClient);
 
228
 
 
229
    pRenderClient->major_version = 0;
 
230
    pRenderClient->minor_version = 0;
 
231
}
 
232
 
 
233
#ifdef PANORAMIX
 
234
RESTYPE XRT_PICTURE;
 
235
#endif
 
236
 
 
237
void
 
238
RenderExtensionInit(void)
 
239
{
 
240
    ExtensionEntry *extEntry;
 
241
 
 
242
    if (!PictureType)
 
243
        return;
 
244
    if (!PictureFinishInit())
 
245
        return;
 
246
    if (!dixRegisterPrivateKey
 
247
        (&RenderClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(RenderClientRec)))
 
248
        return;
 
249
    if (!AddCallback(&ClientStateCallback, RenderClientCallback, 0))
 
250
        return;
 
251
 
 
252
    extEntry = AddExtension(RENDER_NAME, 0, RenderNumberErrors,
 
253
                            ProcRenderDispatch, SProcRenderDispatch,
 
254
                            NULL, StandardMinorOpcode);
 
255
    if (!extEntry)
 
256
        return;
 
257
    RenderErrBase = extEntry->errorBase;
 
258
#ifdef PANORAMIX
 
259
    if (XRT_PICTURE)
 
260
        SetResourceTypeErrorValue(XRT_PICTURE, RenderErrBase + BadPicture);
 
261
#endif
 
262
    SetResourceTypeErrorValue(PictureType, RenderErrBase + BadPicture);
 
263
    SetResourceTypeErrorValue(PictFormatType, RenderErrBase + BadPictFormat);
 
264
    SetResourceTypeErrorValue(GlyphSetType, RenderErrBase + BadGlyphSet);
 
265
}
 
266
 
 
267
static int
 
268
ProcRenderQueryVersion(ClientPtr client)
 
269
{
 
270
    RenderClientPtr pRenderClient = GetRenderClient(client);
 
271
    xRenderQueryVersionReply rep = {
 
272
        .type = X_Reply,
 
273
        .sequenceNumber = client->sequence,
 
274
        .length = 0
 
275
    };
 
276
 
 
277
    REQUEST(xRenderQueryVersionReq);
 
278
 
 
279
    REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
 
280
 
 
281
    pRenderClient->major_version = stuff->majorVersion;
 
282
    pRenderClient->minor_version = stuff->minorVersion;
 
283
 
 
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;
 
288
    }
 
289
    else {
 
290
        rep.majorVersion = SERVER_RENDER_MAJOR_VERSION;
 
291
        rep.minorVersion = SERVER_RENDER_MINOR_VERSION;
 
292
    }
 
293
 
 
294
    if (client->swapped) {
 
295
        swaps(&rep.sequenceNumber);
 
296
        swapl(&rep.length);
 
297
        swapl(&rep.majorVersion);
 
298
        swapl(&rep.minorVersion);
 
299
    }
 
300
    WriteToClient(client, sizeof(xRenderQueryVersionReply), &rep);
 
301
    return Success;
 
302
}
 
303
 
 
304
static VisualPtr
 
305
findVisual(ScreenPtr pScreen, VisualID vid)
 
306
{
 
307
    VisualPtr pVisual;
 
308
    int v;
 
309
 
 
310
    for (v = 0; v < pScreen->numVisuals; v++) {
 
311
        pVisual = pScreen->visuals + v;
 
312
        if (pVisual->vid == vid)
 
313
            return pVisual;
 
314
    }
 
315
    return 0;
 
316
}
 
317
 
 
318
static int
 
319
ProcRenderQueryPictFormats(ClientPtr client)
 
320
{
 
321
    RenderClientPtr pRenderClient = GetRenderClient(client);
 
322
    xRenderQueryPictFormatsReply *reply;
 
323
    xPictScreen *pictScreen;
 
324
    xPictDepth *pictDepth;
 
325
    xPictVisual *pictVisual;
 
326
    xPictFormInfo *pictForm;
 
327
    CARD32 *pictSubpixel;
 
328
    ScreenPtr pScreen;
 
329
    VisualPtr pVisual;
 
330
    DepthPtr pDepth;
 
331
    int v, d;
 
332
    PictureScreenPtr ps;
 
333
    PictFormatPtr pFormat;
 
334
    int nformat;
 
335
    int ndepth;
 
336
    int nvisual;
 
337
    int rlength;
 
338
    int s;
 
339
    int numScreens;
 
340
    int numSubpixel;
 
341
 
 
342
/*    REQUEST(xRenderQueryPictFormatsReq); */
 
343
 
 
344
    REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq);
 
345
 
 
346
#ifdef PANORAMIX
 
347
    if (noPanoramiXExtension)
 
348
        numScreens = screenInfo.numScreens;
 
349
    else
 
350
        numScreens = ((xConnSetup *) ConnectionInfo)->numRoots;
 
351
#else
 
352
    numScreens = screenInfo.numScreens;
 
353
#endif
 
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;
 
359
            ++ndepth;
 
360
 
 
361
            for (v = 0; v < pDepth->numVids; v++) {
 
362
                pVisual = findVisual(pScreen, pDepth->vids[v]);
 
363
                if (pVisual &&
 
364
                    PictureMatchVisual(pScreen, pDepth->depth, pVisual))
 
365
                    ++nvisual;
 
366
            }
 
367
        }
 
368
        ps = GetPictureScreenIfSet(pScreen);
 
369
        if (ps)
 
370
            nformat += ps->nformats;
 
371
    }
 
372
    if (pRenderClient->major_version == 0 && pRenderClient->minor_version < 6)
 
373
        numSubpixel = 0;
 
374
    else
 
375
        numSubpixel = numScreens;
 
376
 
 
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);
 
383
    if (!reply)
 
384
        return BadAlloc;
 
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;
 
393
 
 
394
    pictForm = (xPictFormInfo *) (reply + 1);
 
395
 
 
396
    for (s = 0; s < numScreens; s++) {
 
397
        pScreen = screenInfo.screens[s];
 
398
        ps = GetPictureScreenIfSet(pScreen);
 
399
        if (ps) {
 
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;
 
416
                else
 
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);
 
429
                }
 
430
                pictForm++;
 
431
            }
 
432
        }
 
433
    }
 
434
 
 
435
    pictScreen = (xPictScreen *) pictForm;
 
436
    for (s = 0; s < numScreens; s++) {
 
437
        pScreen = screenInfo.screens[s];
 
438
        pictDepth = (xPictDepth *) (pictScreen + 1);
 
439
        ndepth = 0;
 
440
        for (d = 0; d < pScreen->numDepths; d++) {
 
441
            pictVisual = (xPictVisual *) (pictDepth + 1);
 
442
            pDepth = pScreen->allowedDepths + d;
 
443
 
 
444
            nvisual = 0;
 
445
            for (v = 0; v < pDepth->numVids; v++) {
 
446
                pVisual = findVisual(pScreen, pDepth->vids[v]);
 
447
                if (pVisual && (pFormat = PictureMatchVisual(pScreen,
 
448
                                                             pDepth->depth,
 
449
                                                             pVisual))) {
 
450
                    pictVisual->visual = pVisual->vid;
 
451
                    pictVisual->format = pFormat->id;
 
452
                    if (client->swapped) {
 
453
                        swapl(&pictVisual->visual);
 
454
                        swapl(&pictVisual->format);
 
455
                    }
 
456
                    pictVisual++;
 
457
                    nvisual++;
 
458
                }
 
459
            }
 
460
            pictDepth->depth = pDepth->depth;
 
461
            pictDepth->nPictVisuals = nvisual;
 
462
            if (client->swapped) {
 
463
                swaps(&pictDepth->nPictVisuals);
 
464
            }
 
465
            ndepth++;
 
466
            pictDepth = (xPictDepth *) pictVisual;
 
467
        }
 
468
        pictScreen->nDepth = ndepth;
 
469
        ps = GetPictureScreenIfSet(pScreen);
 
470
        if (ps)
 
471
            pictScreen->fallback = ps->fallback->id;
 
472
        else
 
473
            pictScreen->fallback = 0;
 
474
        if (client->swapped) {
 
475
            swapl(&pictScreen->nDepth);
 
476
            swapl(&pictScreen->fallback);
 
477
        }
 
478
        pictScreen = (xPictScreen *) pictDepth;
 
479
    }
 
480
    pictSubpixel = (CARD32 *) pictScreen;
 
481
 
 
482
    for (s = 0; s < numSubpixel; s++) {
 
483
        pScreen = screenInfo.screens[s];
 
484
        ps = GetPictureScreenIfSet(pScreen);
 
485
        if (ps)
 
486
            *pictSubpixel = ps->subpixel;
 
487
        else
 
488
            *pictSubpixel = SubPixelUnknown;
 
489
        if (client->swapped) {
 
490
            swapl(pictSubpixel);
 
491
        }
 
492
        ++pictSubpixel;
 
493
    }
 
494
 
 
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);
 
503
    }
 
504
    WriteToClient(client, rlength, reply);
 
505
    free(reply);
 
506
    return Success;
 
507
}
 
508
 
 
509
static int
 
510
ProcRenderQueryPictIndexValues(ClientPtr client)
 
511
{
 
512
    PictFormatPtr pFormat;
 
513
    int rc, num;
 
514
    int rlength;
 
515
    int i;
 
516
 
 
517
    REQUEST(xRenderQueryPictIndexValuesReq);
 
518
    xRenderQueryPictIndexValuesReply *reply;
 
519
    xIndexValue *values;
 
520
 
 
521
    REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq);
 
522
 
 
523
    rc = dixLookupResourceByType((void **) &pFormat, stuff->format,
 
524
                                 PictFormatType, client, DixReadAccess);
 
525
    if (rc != Success)
 
526
        return rc;
 
527
 
 
528
    if (pFormat->type != PictTypeIndexed) {
 
529
        client->errorValue = stuff->format;
 
530
        return BadMatch;
 
531
    }
 
532
    num = pFormat->index.nvalues;
 
533
    rlength = (sizeof(xRenderQueryPictIndexValuesReply) +
 
534
               num * sizeof(xIndexValue));
 
535
    reply = (xRenderQueryPictIndexValuesReply *) calloc(1, rlength);
 
536
    if (!reply)
 
537
        return BadAlloc;
 
538
 
 
539
    reply->type = X_Reply;
 
540
    reply->sequenceNumber = client->sequence;
 
541
    reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
 
542
    reply->numIndexValues = num;
 
543
 
 
544
    values = (xIndexValue *) (reply + 1);
 
545
 
 
546
    memcpy(reply + 1, pFormat->index.pValues, num * sizeof(xIndexValue));
 
547
 
 
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);
 
555
        }
 
556
        swaps(&reply->sequenceNumber);
 
557
        swapl(&reply->length);
 
558
        swapl(&reply->numIndexValues);
 
559
    }
 
560
 
 
561
    WriteToClient(client, rlength, reply);
 
562
    free(reply);
 
563
    return Success;
 
564
}
 
565
 
 
566
static int
 
567
ProcRenderQueryDithers(ClientPtr client)
 
568
{
 
569
    return BadImplementation;
 
570
}
 
571
 
 
572
static int
 
573
ProcRenderCreatePicture(ClientPtr client)
 
574
{
 
575
    PicturePtr pPicture;
 
576
    DrawablePtr pDrawable;
 
577
    PictFormatPtr pFormat;
 
578
    int len, error, rc;
 
579
 
 
580
    REQUEST(xRenderCreatePictureReq);
 
581
 
 
582
    REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
 
583
 
 
584
    LEGAL_NEW_RESOURCE(stuff->pid, client);
 
585
    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
 
586
                           DixReadAccess | DixAddAccess);
 
587
    if (rc != Success)
 
588
        return rc;
 
589
 
 
590
    rc = dixLookupResourceByType((void **) &pFormat, stuff->format,
 
591
                                 PictFormatType, client, DixReadAccess);
 
592
    if (rc != Success)
 
593
        return rc;
 
594
 
 
595
    if (pFormat->depth != pDrawable->depth)
 
596
        return BadMatch;
 
597
    len = client->req_len - bytes_to_int32(sizeof(xRenderCreatePictureReq));
 
598
    if (Ones(stuff->mask) != len)
 
599
        return BadLength;
 
600
 
 
601
    pPicture = CreatePicture(stuff->pid,
 
602
                             pDrawable,
 
603
                             pFormat,
 
604
                             stuff->mask, (XID *) (stuff + 1), client, &error);
 
605
    if (!pPicture)
 
606
        return error;
 
607
    if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
 
608
        return BadAlloc;
 
609
    return Success;
 
610
}
 
611
 
 
612
static int
 
613
ProcRenderChangePicture(ClientPtr client)
 
614
{
 
615
    PicturePtr pPicture;
 
616
 
 
617
    REQUEST(xRenderChangePictureReq);
 
618
    int len;
 
619
 
 
620
    REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
 
621
    VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
 
622
 
 
623
    len = client->req_len - bytes_to_int32(sizeof(xRenderChangePictureReq));
 
624
    if (Ones(stuff->mask) != len)
 
625
        return BadLength;
 
626
 
 
627
    return ChangePicture(pPicture, stuff->mask, (XID *) (stuff + 1),
 
628
                         (DevUnion *) 0, client);
 
629
}
 
630
 
 
631
static int
 
632
ProcRenderSetPictureClipRectangles(ClientPtr client)
 
633
{
 
634
    REQUEST(xRenderSetPictureClipRectanglesReq);
 
635
    PicturePtr pPicture;
 
636
    int nr;
 
637
 
 
638
    REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
 
639
    VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
 
640
    if (!pPicture->pDrawable)
 
641
        return RenderErrBase + BadPicture;
 
642
 
 
643
    nr = (client->req_len << 2) - sizeof(xRenderSetPictureClipRectanglesReq);
 
644
    if (nr & 4)
 
645
        return BadLength;
 
646
    nr >>= 3;
 
647
    return SetPictureClipRects(pPicture,
 
648
                               stuff->xOrigin, stuff->yOrigin,
 
649
                               nr, (xRectangle *) &stuff[1]);
 
650
}
 
651
 
 
652
static int
 
653
ProcRenderFreePicture(ClientPtr client)
 
654
{
 
655
    PicturePtr pPicture;
 
656
 
 
657
    REQUEST(xRenderFreePictureReq);
 
658
 
 
659
    REQUEST_SIZE_MATCH(xRenderFreePictureReq);
 
660
 
 
661
    VERIFY_PICTURE(pPicture, stuff->picture, client, DixDestroyAccess);
 
662
    FreeResource(stuff->picture, RT_NONE);
 
663
    return Success;
 
664
}
 
665
 
 
666
static Bool
 
667
PictOpValid(CARD8 op)
 
668
{
 
669
    if ( /*PictOpMinimum <= op && */ op <= PictOpMaximum)
 
670
        return TRUE;
 
671
    if (PictOpDisjointMinimum <= op && op <= PictOpDisjointMaximum)
 
672
        return TRUE;
 
673
    if (PictOpConjointMinimum <= op && op <= PictOpConjointMaximum)
 
674
        return TRUE;
 
675
    if (PictOpBlendMinimum <= op && op <= PictOpBlendMaximum)
 
676
        return TRUE;
 
677
    return FALSE;
 
678
}
 
679
 
 
680
static int
 
681
ProcRenderComposite(ClientPtr client)
 
682
{
 
683
    PicturePtr pSrc, pMask, pDst;
 
684
 
 
685
    REQUEST(xRenderCompositeReq);
 
686
 
 
687
    REQUEST_SIZE_MATCH(xRenderCompositeReq);
 
688
    if (!PictOpValid(stuff->op)) {
 
689
        client->errorValue = stuff->op;
 
690
        return BadValue;
 
691
    }
 
692
    VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
 
693
    if (!pDst->pDrawable)
 
694
        return BadDrawable;
 
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 &&
 
699
                                                                   pMask->
 
700
                                                                   pDrawable &&
 
701
                                                                   pDst->
 
702
                                                                   pDrawable->
 
703
                                                                   pScreen !=
 
704
                                                                   pMask->
 
705
                                                                   pDrawable->
 
706
                                                                   pScreen))
 
707
        return BadMatch;
 
708
    CompositePicture(stuff->op,
 
709
                     pSrc,
 
710
                     pMask,
 
711
                     pDst,
 
712
                     stuff->xSrc,
 
713
                     stuff->ySrc,
 
714
                     stuff->xMask,
 
715
                     stuff->yMask,
 
716
                     stuff->xDst, stuff->yDst, stuff->width, stuff->height);
 
717
    return Success;
 
718
}
 
719
 
 
720
static int
 
721
ProcRenderScale(ClientPtr client)
 
722
{
 
723
    return BadImplementation;
 
724
}
 
725
 
 
726
static int
 
727
ProcRenderTrapezoids(ClientPtr client)
 
728
{
 
729
    int rc, ntraps;
 
730
    PicturePtr pSrc, pDst;
 
731
    PictFormatPtr pFormat;
 
732
 
 
733
    REQUEST(xRenderTrapezoidsReq);
 
734
 
 
735
    REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq);
 
736
    if (!PictOpValid(stuff->op)) {
 
737
        client->errorValue = stuff->op;
 
738
        return BadValue;
 
739
    }
 
740
    VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
 
741
    VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
 
742
    if (!pDst->pDrawable)
 
743
        return BadDrawable;
 
744
    if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
 
745
        return BadMatch;
 
746
    if (stuff->maskFormat) {
 
747
        rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat,
 
748
                                     PictFormatType, client, DixReadAccess);
 
749
        if (rc != Success)
 
750
            return rc;
 
751
    }
 
752
    else
 
753
        pFormat = 0;
 
754
    ntraps = (client->req_len << 2) - sizeof(xRenderTrapezoidsReq);
 
755
    if (ntraps % sizeof(xTrapezoid))
 
756
        return BadLength;
 
757
    ntraps /= sizeof(xTrapezoid);
 
758
    if (ntraps)
 
759
        CompositeTrapezoids(stuff->op, pSrc, pDst, pFormat,
 
760
                            stuff->xSrc, stuff->ySrc,
 
761
                            ntraps, (xTrapezoid *) &stuff[1]);
 
762
    return Success;
 
763
}
 
764
 
 
765
static int
 
766
ProcRenderTriangles(ClientPtr client)
 
767
{
 
768
    int rc, ntris;
 
769
    PicturePtr pSrc, pDst;
 
770
    PictFormatPtr pFormat;
 
771
 
 
772
    REQUEST(xRenderTrianglesReq);
 
773
 
 
774
    REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
 
775
    if (!PictOpValid(stuff->op)) {
 
776
        client->errorValue = stuff->op;
 
777
        return BadValue;
 
778
    }
 
779
    VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
 
780
    VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
 
781
    if (!pDst->pDrawable)
 
782
        return BadDrawable;
 
783
    if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
 
784
        return BadMatch;
 
785
    if (stuff->maskFormat) {
 
786
        rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat,
 
787
                                     PictFormatType, client, DixReadAccess);
 
788
        if (rc != Success)
 
789
            return rc;
 
790
    }
 
791
    else
 
792
        pFormat = 0;
 
793
    ntris = (client->req_len << 2) - sizeof(xRenderTrianglesReq);
 
794
    if (ntris % sizeof(xTriangle))
 
795
        return BadLength;
 
796
    ntris /= sizeof(xTriangle);
 
797
    if (ntris)
 
798
        CompositeTriangles(stuff->op, pSrc, pDst, pFormat,
 
799
                           stuff->xSrc, stuff->ySrc,
 
800
                           ntris, (xTriangle *) &stuff[1]);
 
801
    return Success;
 
802
}
 
803
 
 
804
static int
 
805
ProcRenderTriStrip(ClientPtr client)
 
806
{
 
807
    int rc, npoints;
 
808
    PicturePtr pSrc, pDst;
 
809
    PictFormatPtr pFormat;
 
810
 
 
811
    REQUEST(xRenderTrianglesReq);
 
812
 
 
813
    REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
 
814
    if (!PictOpValid(stuff->op)) {
 
815
        client->errorValue = stuff->op;
 
816
        return BadValue;
 
817
    }
 
818
    VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
 
819
    VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
 
820
    if (!pDst->pDrawable)
 
821
        return BadDrawable;
 
822
    if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
 
823
        return BadMatch;
 
824
    if (stuff->maskFormat) {
 
825
        rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat,
 
826
                                     PictFormatType, client, DixReadAccess);
 
827
        if (rc != Success)
 
828
            return rc;
 
829
    }
 
830
    else
 
831
        pFormat = 0;
 
832
    npoints = ((client->req_len << 2) - sizeof(xRenderTriStripReq));
 
833
    if (npoints & 4)
 
834
        return BadLength;
 
835
    npoints >>= 3;
 
836
    if (npoints >= 3)
 
837
        CompositeTriStrip(stuff->op, pSrc, pDst, pFormat,
 
838
                          stuff->xSrc, stuff->ySrc,
 
839
                          npoints, (xPointFixed *) &stuff[1]);
 
840
    return Success;
 
841
}
 
842
 
 
843
static int
 
844
ProcRenderTriFan(ClientPtr client)
 
845
{
 
846
    int rc, npoints;
 
847
    PicturePtr pSrc, pDst;
 
848
    PictFormatPtr pFormat;
 
849
 
 
850
    REQUEST(xRenderTrianglesReq);
 
851
 
 
852
    REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
 
853
    if (!PictOpValid(stuff->op)) {
 
854
        client->errorValue = stuff->op;
 
855
        return BadValue;
 
856
    }
 
857
    VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
 
858
    VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
 
859
    if (!pDst->pDrawable)
 
860
        return BadDrawable;
 
861
    if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
 
862
        return BadMatch;
 
863
    if (stuff->maskFormat) {
 
864
        rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat,
 
865
                                     PictFormatType, client, DixReadAccess);
 
866
        if (rc != Success)
 
867
            return rc;
 
868
    }
 
869
    else
 
870
        pFormat = 0;
 
871
    npoints = ((client->req_len << 2) - sizeof(xRenderTriStripReq));
 
872
    if (npoints & 4)
 
873
        return BadLength;
 
874
    npoints >>= 3;
 
875
    if (npoints >= 3)
 
876
        CompositeTriFan(stuff->op, pSrc, pDst, pFormat,
 
877
                        stuff->xSrc, stuff->ySrc,
 
878
                        npoints, (xPointFixed *) &stuff[1]);
 
879
    return Success;
 
880
}
 
881
 
 
882
static int
 
883
ProcRenderColorTrapezoids(ClientPtr client)
 
884
{
 
885
    return BadImplementation;
 
886
}
 
887
 
 
888
static int
 
889
ProcRenderColorTriangles(ClientPtr client)
 
890
{
 
891
    return BadImplementation;
 
892
}
 
893
 
 
894
static int
 
895
ProcRenderTransform(ClientPtr client)
 
896
{
 
897
    return BadImplementation;
 
898
}
 
899
 
 
900
static int
 
901
ProcRenderCreateGlyphSet(ClientPtr client)
 
902
{
 
903
    GlyphSetPtr glyphSet;
 
904
    PictFormatPtr format;
 
905
    int rc, f;
 
906
 
 
907
    REQUEST(xRenderCreateGlyphSetReq);
 
908
 
 
909
    REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
 
910
 
 
911
    LEGAL_NEW_RESOURCE(stuff->gsid, client);
 
912
    rc = dixLookupResourceByType((void **) &format, stuff->format,
 
913
                                 PictFormatType, client, DixReadAccess);
 
914
    if (rc != Success)
 
915
        return rc;
 
916
 
 
917
    switch (format->depth) {
 
918
    case 1:
 
919
        f = GlyphFormat1;
 
920
        break;
 
921
    case 4:
 
922
        f = GlyphFormat4;
 
923
        break;
 
924
    case 8:
 
925
        f = GlyphFormat8;
 
926
        break;
 
927
    case 16:
 
928
        f = GlyphFormat16;
 
929
        break;
 
930
    case 32:
 
931
        f = GlyphFormat32;
 
932
        break;
 
933
    default:
 
934
        return BadMatch;
 
935
    }
 
936
    if (format->type != PictTypeDirect)
 
937
        return BadMatch;
 
938
    glyphSet = AllocateGlyphSet(f, format);
 
939
    if (!glyphSet)
 
940
        return BadAlloc;
 
941
    /* security creation/labeling check */
 
942
    rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->gsid, GlyphSetType,
 
943
                  glyphSet, RT_NONE, NULL, DixCreateAccess);
 
944
    if (rc != Success)
 
945
        return rc;
 
946
    if (!AddResource(stuff->gsid, GlyphSetType, (void *) glyphSet))
 
947
        return BadAlloc;
 
948
    return Success;
 
949
}
 
950
 
 
951
static int
 
952
ProcRenderReferenceGlyphSet(ClientPtr client)
 
953
{
 
954
    GlyphSetPtr glyphSet;
 
955
    int rc;
 
956
 
 
957
    REQUEST(xRenderReferenceGlyphSetReq);
 
958
 
 
959
    REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq);
 
960
 
 
961
    LEGAL_NEW_RESOURCE(stuff->gsid, client);
 
962
 
 
963
    rc = dixLookupResourceByType((void **) &glyphSet, stuff->existing,
 
964
                                 GlyphSetType, client, DixGetAttrAccess);
 
965
    if (rc != Success) {
 
966
        client->errorValue = stuff->existing;
 
967
        return rc;
 
968
    }
 
969
    glyphSet->refcnt++;
 
970
    if (!AddResource(stuff->gsid, GlyphSetType, (void *) glyphSet))
 
971
        return BadAlloc;
 
972
    return Success;
 
973
}
 
974
 
 
975
#define NLOCALDELTA     64
 
976
#define NLOCALGLYPH     256
 
977
 
 
978
static int
 
979
ProcRenderFreeGlyphSet(ClientPtr client)
 
980
{
 
981
    GlyphSetPtr glyphSet;
 
982
    int rc;
 
983
 
 
984
    REQUEST(xRenderFreeGlyphSetReq);
 
985
 
 
986
    REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
 
987
    rc = dixLookupResourceByType((void **) &glyphSet, stuff->glyphset,
 
988
                                 GlyphSetType, client, DixDestroyAccess);
 
989
    if (rc != Success) {
 
990
        client->errorValue = stuff->glyphset;
 
991
        return rc;
 
992
    }
 
993
    FreeResource(stuff->glyphset, RT_NONE);
 
994
    return Success;
 
995
}
 
996
 
 
997
typedef struct _GlyphNew {
 
998
    Glyph id;
 
999
    GlyphPtr glyph;
 
1000
    Bool found;
 
1001
    unsigned char sha1[20];
 
1002
} GlyphNewRec, *GlyphNewPtr;
 
1003
 
 
1004
#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
 
1005
 
 
1006
static int
 
1007
ProcRenderAddGlyphs(ClientPtr client)
 
1008
{
 
1009
    GlyphSetPtr glyphSet;
 
1010
 
 
1011
    REQUEST(xRenderAddGlyphsReq);
 
1012
    GlyphNewRec glyphsLocal[NLOCALGLYPH];
 
1013
    GlyphNewPtr glyphsBase, glyphs, glyph_new;
 
1014
    int remain, nglyphs;
 
1015
    CARD32 *gids;
 
1016
    xGlyphInfo *gi;
 
1017
    CARD8 *bits;
 
1018
    unsigned int size;
 
1019
    int err;
 
1020
    int i, screen;
 
1021
    PicturePtr pSrc = NULL, pDst = NULL;
 
1022
    PixmapPtr pSrcPix = NULL, pDstPix = NULL;
 
1023
    CARD32 component_alpha;
 
1024
 
 
1025
    REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
 
1026
    err =
 
1027
        dixLookupResourceByType((void **) &glyphSet, stuff->glyphset,
 
1028
                                GlyphSetType, client, DixAddAccess);
 
1029
    if (err != Success) {
 
1030
        client->errorValue = stuff->glyphset;
 
1031
        return err;
 
1032
    }
 
1033
 
 
1034
    err = BadAlloc;
 
1035
    nglyphs = stuff->nglyphs;
 
1036
    if (nglyphs > UINT32_MAX / sizeof(GlyphNewRec))
 
1037
        return BadAlloc;
 
1038
 
 
1039
    component_alpha = NeedsComponent(glyphSet->format->format);
 
1040
 
 
1041
    if (nglyphs <= NLOCALGLYPH) {
 
1042
        memset(glyphsLocal, 0, sizeof(glyphsLocal));
 
1043
        glyphsBase = glyphsLocal;
 
1044
    }
 
1045
    else {
 
1046
        glyphsBase = (GlyphNewPtr) calloc(nglyphs, sizeof(GlyphNewRec));
 
1047
        if (!glyphsBase)
 
1048
            return BadAlloc;
 
1049
    }
 
1050
 
 
1051
    remain = (client->req_len << 2) - sizeof(xRenderAddGlyphsReq);
 
1052
 
 
1053
    glyphs = glyphsBase;
 
1054
 
 
1055
    gids = (CARD32 *) (stuff + 1);
 
1056
    gi = (xGlyphInfo *) (gids + nglyphs);
 
1057
    bits = (CARD8 *) (gi + nglyphs);
 
1058
    remain -= (sizeof(CARD32) + sizeof(xGlyphInfo)) * nglyphs;
 
1059
 
 
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))) {
 
1065
        err = BadLength;
 
1066
        goto bail;
 
1067
    }
 
1068
 
 
1069
    for (i = 0; i < nglyphs; i++) {
 
1070
        size_t padded_width;
 
1071
 
 
1072
        glyph_new = &glyphs[i];
 
1073
 
 
1074
        padded_width = PixmapBytePad(gi[i].width, glyphSet->format->depth);
 
1075
 
 
1076
        if (gi[i].height &&
 
1077
            padded_width > (UINT32_MAX - sizeof(GlyphRec)) / gi[i].height)
 
1078
            break;
 
1079
 
 
1080
        size = gi[i].height * padded_width;
 
1081
        if (remain < size)
 
1082
            break;
 
1083
 
 
1084
        err = HashGlyph(&gi[i], bits, size, glyph_new->sha1);
 
1085
        if (err)
 
1086
            goto bail;
 
1087
 
 
1088
        glyph_new->glyph = FindGlyphByHash(glyph_new->sha1, glyphSet->fdepth);
 
1089
 
 
1090
        if (glyph_new->glyph && glyph_new->glyph != DeletedGlyph) {
 
1091
            glyph_new->found = TRUE;
 
1092
        }
 
1093
        else {
 
1094
            GlyphPtr glyph;
 
1095
 
 
1096
            glyph_new->found = FALSE;
 
1097
            glyph_new->glyph = glyph = AllocateGlyph(&gi[i], glyphSet->fdepth);
 
1098
            if (!glyph) {
 
1099
                err = BadAlloc;
 
1100
                goto bail;
 
1101
            }
 
1102
 
 
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;
 
1107
                ScreenPtr pScreen;
 
1108
                int error;
 
1109
 
 
1110
                /* Skip work if it's invisibly small anyway */
 
1111
                if (!width || !height)
 
1112
                    break;
 
1113
 
 
1114
                pScreen = screenInfo.screens[screen];
 
1115
                pSrcPix = GetScratchPixmapHeader(pScreen,
 
1116
                                                 width, height,
 
1117
                                                 depth, depth, -1, bits);
 
1118
                if (!pSrcPix) {
 
1119
                    err = BadAlloc;
 
1120
                    goto bail;
 
1121
                }
 
1122
 
 
1123
                pSrc = CreatePicture(0, &pSrcPix->drawable,
 
1124
                                     glyphSet->format, 0, NULL,
 
1125
                                     serverClient, &error);
 
1126
                if (!pSrc) {
 
1127
                    err = BadAlloc;
 
1128
                    goto bail;
 
1129
                }
 
1130
 
 
1131
                pDstPix = (pScreen->CreatePixmap) (pScreen,
 
1132
                                                   width, height, depth,
 
1133
                                                   CREATE_PIXMAP_USAGE_GLYPH_PICTURE);
 
1134
 
 
1135
                if (!pDstPix) {
 
1136
                    err = BadAlloc;
 
1137
                    goto bail;
 
1138
                }
 
1139
 
 
1140
                pDst = CreatePicture(0, &pDstPix->drawable,
 
1141
                                  glyphSet->format,
 
1142
                                  CPComponentAlpha, &component_alpha,
 
1143
                                  serverClient, &error);
 
1144
                SetGlyphPicture(glyph, pScreen, pDst);
 
1145
 
 
1146
                /* The picture takes a reference to the pixmap, so we
 
1147
                   drop ours. */
 
1148
                (pScreen->DestroyPixmap) (pDstPix);
 
1149
                pDstPix = NULL;
 
1150
 
 
1151
                if (!pDst) {
 
1152
                    err = BadAlloc;
 
1153
                    goto bail;
 
1154
                }
 
1155
 
 
1156
                CompositePicture(PictOpSrc,
 
1157
                                 pSrc,
 
1158
                                 None, pDst, 0, 0, 0, 0, 0, 0, width, height);
 
1159
 
 
1160
                FreePicture((void *) pSrc, 0);
 
1161
                pSrc = NULL;
 
1162
                FreeScratchPixmapHeader(pSrcPix);
 
1163
                pSrcPix = NULL;
 
1164
            }
 
1165
 
 
1166
            memcpy(glyph_new->glyph->sha1, glyph_new->sha1, 20);
 
1167
        }
 
1168
 
 
1169
        glyph_new->id = gids[i];
 
1170
 
 
1171
        if (size & 3)
 
1172
            size += 4 - (size & 3);
 
1173
        bits += size;
 
1174
        remain -= size;
 
1175
    }
 
1176
    if (remain || i < nglyphs) {
 
1177
        err = BadLength;
 
1178
        goto bail;
 
1179
    }
 
1180
    if (!ResizeGlyphSet(glyphSet, nglyphs)) {
 
1181
        err = BadAlloc;
 
1182
        goto bail;
 
1183
    }
 
1184
    for (i = 0; i < nglyphs; i++)
 
1185
        AddGlyph(glyphSet, glyphs[i].glyph, glyphs[i].id);
 
1186
 
 
1187
    if (glyphsBase != glyphsLocal)
 
1188
        free(glyphsBase);
 
1189
    return Success;
 
1190
 bail:
 
1191
    if (pSrc)
 
1192
        FreePicture((void *) pSrc, 0);
 
1193
    if (pSrcPix)
 
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)
 
1199
        free(glyphsBase);
 
1200
    return err;
 
1201
}
 
1202
 
 
1203
static int
 
1204
ProcRenderAddGlyphsFromPicture(ClientPtr client)
 
1205
{
 
1206
    return BadImplementation;
 
1207
}
 
1208
 
 
1209
static int
 
1210
ProcRenderFreeGlyphs(ClientPtr client)
 
1211
{
 
1212
    REQUEST(xRenderFreeGlyphsReq);
 
1213
    GlyphSetPtr glyphSet;
 
1214
    int rc, nglyph;
 
1215
    CARD32 *gids;
 
1216
    CARD32 glyph;
 
1217
 
 
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;
 
1223
        return rc;
 
1224
    }
 
1225
    nglyph =
 
1226
        bytes_to_int32((client->req_len << 2) - sizeof(xRenderFreeGlyphsReq));
 
1227
    gids = (CARD32 *) (stuff + 1);
 
1228
    while (nglyph-- > 0) {
 
1229
        glyph = *gids++;
 
1230
        if (!DeleteGlyph(glyphSet, glyph)) {
 
1231
            client->errorValue = glyph;
 
1232
            return RenderErrBase + BadGlyph;
 
1233
        }
 
1234
    }
 
1235
    return Success;
 
1236
}
 
1237
 
 
1238
static int
 
1239
ProcRenderCompositeGlyphs(ClientPtr client)
 
1240
{
 
1241
    GlyphSetPtr glyphSet;
 
1242
    GlyphSet gs;
 
1243
    PicturePtr pSrc, pDst;
 
1244
    PictFormatPtr pFormat;
 
1245
    GlyphListRec listsLocal[NLOCALDELTA];
 
1246
    GlyphListPtr lists, listsBase;
 
1247
    GlyphPtr glyphsLocal[NLOCALGLYPH];
 
1248
    Glyph glyph;
 
1249
    GlyphPtr *glyphs, *glyphsBase;
 
1250
    xGlyphElt *elt;
 
1251
    CARD8 *buffer, *end;
 
1252
    int nglyph;
 
1253
    int nlist;
 
1254
    int space;
 
1255
    int size;
 
1256
    int rc, n;
 
1257
 
 
1258
    REQUEST(xRenderCompositeGlyphsReq);
 
1259
 
 
1260
    REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);
 
1261
 
 
1262
    switch (stuff->renderReqType) {
 
1263
    default:
 
1264
        size = 1;
 
1265
        break;
 
1266
    case X_RenderCompositeGlyphs16:
 
1267
        size = 2;
 
1268
        break;
 
1269
    case X_RenderCompositeGlyphs32:
 
1270
        size = 4;
 
1271
        break;
 
1272
    }
 
1273
 
 
1274
    if (!PictOpValid(stuff->op)) {
 
1275
        client->errorValue = stuff->op;
 
1276
        return BadValue;
 
1277
    }
 
1278
    VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
 
1279
    VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
 
1280
    if (!pDst->pDrawable)
 
1281
        return BadDrawable;
 
1282
    if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
 
1283
        return BadMatch;
 
1284
    if (stuff->maskFormat) {
 
1285
        rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat,
 
1286
                                     PictFormatType, client, DixReadAccess);
 
1287
        if (rc != Success)
 
1288
            return rc;
 
1289
    }
 
1290
    else
 
1291
        pFormat = 0;
 
1292
 
 
1293
    rc = dixLookupResourceByType((void **) &glyphSet, stuff->glyphset,
 
1294
                                 GlyphSetType, client, DixUseAccess);
 
1295
    if (rc != Success)
 
1296
        return rc;
 
1297
 
 
1298
    buffer = (CARD8 *) (stuff + 1);
 
1299
    end = (CARD8 *) stuff + (client->req_len << 2);
 
1300
    nglyph = 0;
 
1301
    nlist = 0;
 
1302
    while (buffer + sizeof(xGlyphElt) < end) {
 
1303
        elt = (xGlyphElt *) buffer;
 
1304
        buffer += sizeof(xGlyphElt);
 
1305
 
 
1306
        if (elt->len == 0xff) {
 
1307
            buffer += 4;
 
1308
        }
 
1309
        else {
 
1310
            nlist++;
 
1311
            nglyph += elt->len;
 
1312
            space = size * elt->len;
 
1313
            if (space & 3)
 
1314
                space += 4 - (space & 3);
 
1315
            buffer += space;
 
1316
        }
 
1317
    }
 
1318
    if (nglyph <= NLOCALGLYPH)
 
1319
        glyphsBase = glyphsLocal;
 
1320
    else {
 
1321
        glyphsBase = xallocarray(nglyph, sizeof(GlyphPtr));
 
1322
        if (!glyphsBase)
 
1323
            return BadAlloc;
 
1324
    }
 
1325
    if (nlist <= NLOCALDELTA)
 
1326
        listsBase = listsLocal;
 
1327
    else {
 
1328
        listsBase = xallocarray(nlist, sizeof(GlyphListRec));
 
1329
        if (!listsBase) {
 
1330
            rc = BadAlloc;
 
1331
            goto bail;
 
1332
        }
 
1333
    }
 
1334
    buffer = (CARD8 *) (stuff + 1);
 
1335
    glyphs = glyphsBase;
 
1336
    lists = listsBase;
 
1337
    while (buffer + sizeof(xGlyphElt) < end) {
 
1338
        elt = (xGlyphElt *) buffer;
 
1339
        buffer += sizeof(xGlyphElt);
 
1340
 
 
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,
 
1346
                                             DixUseAccess);
 
1347
                if (rc != Success)
 
1348
                    goto bail;
 
1349
            }
 
1350
            buffer += 4;
 
1351
        }
 
1352
        else {
 
1353
            lists->xOff = elt->deltax;
 
1354
            lists->yOff = elt->deltay;
 
1355
            lists->format = glyphSet->format;
 
1356
            lists->len = 0;
 
1357
            n = elt->len;
 
1358
            while (n--) {
 
1359
                if (buffer + size <= end) {
 
1360
                    switch (size) {
 
1361
                    case 1:
 
1362
                        glyph = *((CARD8 *) buffer);
 
1363
                        break;
 
1364
                    case 2:
 
1365
                        glyph = *((CARD16 *) buffer);
 
1366
                        break;
 
1367
                    case 4:
 
1368
                    default:
 
1369
                        glyph = *((CARD32 *) buffer);
 
1370
                        break;
 
1371
                    }
 
1372
                    if ((*glyphs = FindGlyph(glyphSet, glyph))) {
 
1373
                        lists->len++;
 
1374
                        glyphs++;
 
1375
                    }
 
1376
                }
 
1377
                buffer += size;
 
1378
            }
 
1379
            space = size * elt->len;
 
1380
            if (space & 3)
 
1381
                buffer += 4 - (space & 3);
 
1382
            lists++;
 
1383
        }
 
1384
    }
 
1385
    if (buffer > end) {
 
1386
        rc = BadLength;
 
1387
        goto bail;
 
1388
    }
 
1389
 
 
1390
    CompositeGlyphs(stuff->op,
 
1391
                    pSrc,
 
1392
                    pDst,
 
1393
                    pFormat,
 
1394
                    stuff->xSrc, stuff->ySrc, nlist, listsBase, glyphsBase);
 
1395
    rc = Success;
 
1396
 
 
1397
 bail:
 
1398
    if (glyphsBase != glyphsLocal)
 
1399
        free(glyphsBase);
 
1400
    if (listsBase != listsLocal)
 
1401
        free(listsBase);
 
1402
    return rc;
 
1403
}
 
1404
 
 
1405
static int
 
1406
ProcRenderFillRectangles(ClientPtr client)
 
1407
{
 
1408
    PicturePtr pDst;
 
1409
    int things;
 
1410
 
 
1411
    REQUEST(xRenderFillRectanglesReq);
 
1412
 
 
1413
    REQUEST_AT_LEAST_SIZE(xRenderFillRectanglesReq);
 
1414
    if (!PictOpValid(stuff->op)) {
 
1415
        client->errorValue = stuff->op;
 
1416
        return BadValue;
 
1417
    }
 
1418
    VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess);
 
1419
    if (!pDst->pDrawable)
 
1420
        return BadDrawable;
 
1421
 
 
1422
    things = (client->req_len << 2) - sizeof(xRenderFillRectanglesReq);
 
1423
    if (things & 4)
 
1424
        return BadLength;
 
1425
    things >>= 3;
 
1426
 
 
1427
    CompositeRects(stuff->op,
 
1428
                   pDst, &stuff->color, things, (xRectangle *) &stuff[1]);
 
1429
 
 
1430
    return Success;
 
1431
}
 
1432
 
 
1433
static void
 
1434
RenderSetBit(unsigned char *line, int x, int bit)
 
1435
{
 
1436
    unsigned char mask;
 
1437
 
 
1438
    if (screenInfo.bitmapBitOrder == LSBFirst)
 
1439
        mask = (1 << (x & 7));
 
1440
    else
 
1441
        mask = (0x80 >> (x & 7));
 
1442
    /* XXX assumes byte order is host byte order */
 
1443
    line += (x >> 3);
 
1444
    if (bit)
 
1445
        *line |= mask;
 
1446
    else
 
1447
        *line &= ~mask;
 
1448
}
 
1449
 
 
1450
#define DITHER_DIM 2
 
1451
 
 
1452
static CARD32 orderedDither[DITHER_DIM][DITHER_DIM] = {
 
1453
    {1, 3,},
 
1454
    {4, 2,},
 
1455
};
 
1456
 
 
1457
#define DITHER_SIZE  ((sizeof orderedDither / sizeof orderedDither[0][0]) + 1)
 
1458
 
 
1459
static int
 
1460
ProcRenderCreateCursor(ClientPtr client)
 
1461
{
 
1462
    REQUEST(xRenderCreateCursorReq);
 
1463
    PicturePtr pSrc;
 
1464
    ScreenPtr pScreen;
 
1465
    unsigned short width, height;
 
1466
    CARD32 *argbbits, *argb;
 
1467
    unsigned char *srcbits, *srcline;
 
1468
    unsigned char *mskbits, *mskline;
 
1469
    int stride;
 
1470
    int x, y;
 
1471
    int nbytes_mono;
 
1472
    CursorMetricRec cm;
 
1473
    CursorPtr pCursor;
 
1474
    CARD32 twocolor[3];
 
1475
    int rc, ncolor;
 
1476
 
 
1477
    REQUEST_SIZE_MATCH(xRenderCreateCursorReq);
 
1478
    LEGAL_NEW_RESOURCE(stuff->cid, client);
 
1479
 
 
1480
    VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
 
1481
    if (!pSrc->pDrawable)
 
1482
        return BadDrawable;
 
1483
    pScreen = pSrc->pDrawable->pScreen;
 
1484
    width = pSrc->pDrawable->width;
 
1485
    height = pSrc->pDrawable->height;
 
1486
    if (height && width > UINT32_MAX / (height * sizeof(CARD32)))
 
1487
        return BadAlloc;
 
1488
    if (stuff->x > width || stuff->y > height)
 
1489
        return BadMatch;
 
1490
    argbbits = malloc(width * height * sizeof(CARD32));
 
1491
    if (!argbbits)
 
1492
        return BadAlloc;
 
1493
 
 
1494
    stride = BitmapBytePad(width);
 
1495
    nbytes_mono = stride * height;
 
1496
    srcbits = calloc(1, nbytes_mono);
 
1497
    if (!srcbits) {
 
1498
        free(argbbits);
 
1499
        return BadAlloc;
 
1500
    }
 
1501
    mskbits = calloc(1, nbytes_mono);
 
1502
    if (!mskbits) {
 
1503
        free(argbbits);
 
1504
        free(srcbits);
 
1505
        return BadAlloc;
 
1506
    }
 
1507
 
 
1508
    if (pSrc->format == PICT_a8r8g8b8) {
 
1509
        (*pScreen->GetImage) (pSrc->pDrawable,
 
1510
                              0, 0, width, height, ZPixmap,
 
1511
                              0xffffffff, (void *) argbbits);
 
1512
    }
 
1513
    else {
 
1514
        PixmapPtr pPixmap;
 
1515
        PicturePtr pPicture;
 
1516
        PictFormatPtr pFormat;
 
1517
        int error;
 
1518
 
 
1519
        pFormat = PictureMatchFormat(pScreen, 32, PICT_a8r8g8b8);
 
1520
        if (!pFormat) {
 
1521
            free(argbbits);
 
1522
            free(srcbits);
 
1523
            free(mskbits);
 
1524
            return BadImplementation;
 
1525
        }
 
1526
        pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 32,
 
1527
                                            CREATE_PIXMAP_USAGE_SCRATCH);
 
1528
        if (!pPixmap) {
 
1529
            free(argbbits);
 
1530
            free(srcbits);
 
1531
            free(mskbits);
 
1532
            return BadAlloc;
 
1533
        }
 
1534
        pPicture = CreatePicture(0, &pPixmap->drawable, pFormat, 0, 0,
 
1535
                                 client, &error);
 
1536
        if (!pPicture) {
 
1537
            free(argbbits);
 
1538
            free(srcbits);
 
1539
            free(mskbits);
 
1540
            return error;
 
1541
        }
 
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);
 
1549
    }
 
1550
    /*
 
1551
     * Check whether the cursor can be directly supported by
 
1552
     * the core cursor code
 
1553
     */
 
1554
    ncolor = 0;
 
1555
    argb = argbbits;
 
1556
    for (y = 0; ncolor <= 2 && y < height; y++) {
 
1557
        for (x = 0; ncolor <= 2 && x < width; x++) {
 
1558
            CARD32 p = *argb++;
 
1559
            CARD32 a = (p >> 24);
 
1560
 
 
1561
            if (a == 0)         /* transparent */
 
1562
                continue;
 
1563
            if (a == 0xff) {    /* opaque */
 
1564
                int n;
 
1565
 
 
1566
                for (n = 0; n < ncolor; n++)
 
1567
                    if (p == twocolor[n])
 
1568
                        break;
 
1569
                if (n == ncolor)
 
1570
                    twocolor[ncolor++] = p;
 
1571
            }
 
1572
            else
 
1573
                ncolor = 3;
 
1574
        }
 
1575
    }
 
1576
 
 
1577
    /*
 
1578
     * Convert argb image to two plane cursor
 
1579
     */
 
1580
    srcline = srcbits;
 
1581
    mskline = mskbits;
 
1582
    argb = argbbits;
 
1583
    for (y = 0; y < height; y++) {
 
1584
        for (x = 0; x < width; x++) {
 
1585
            CARD32 p = *argb++;
 
1586
 
 
1587
            if (ncolor <= 2) {
 
1588
                CARD32 a = ((p >> 24));
 
1589
 
 
1590
                RenderSetBit(mskline, x, a != 0);
 
1591
                RenderSetBit(srcline, x, a != 0 && p == twocolor[0]);
 
1592
            }
 
1593
            else {
 
1594
                CARD32 a = ((p >> 24) * DITHER_SIZE + 127) / 255;
 
1595
                CARD32 i = ((CvtR8G8B8toY15(p) >> 7) * DITHER_SIZE + 127) / 255;
 
1596
                CARD32 d =
 
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);
 
1602
            }
 
1603
        }
 
1604
        srcline += stride;
 
1605
        mskline += stride;
 
1606
    }
 
1607
    /*
 
1608
     * Dither to white and black if the cursor has more than two colors
 
1609
     */
 
1610
    if (ncolor > 2) {
 
1611
        twocolor[0] = 0xff000000;
 
1612
        twocolor[1] = 0xffffffff;
 
1613
    }
 
1614
    else {
 
1615
        free(argbbits);
 
1616
        argbbits = 0;
 
1617
    }
 
1618
 
 
1619
#define GetByte(p,s)    (((p) >> (s)) & 0xff)
 
1620
#define GetColor(p,s)   (GetByte(p,s) | (GetByte(p,s) << 8))
 
1621
 
 
1622
    cm.width = width;
 
1623
    cm.height = height;
 
1624
    cm.xhot = stuff->x;
 
1625
    cm.yhot = stuff->y;
 
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);
 
1634
    if (rc != Success)
 
1635
        goto bail;
 
1636
    if (!AddResource(stuff->cid, RT_CURSOR, (void *) pCursor)) {
 
1637
        rc = BadAlloc;
 
1638
        goto bail;
 
1639
    }
 
1640
 
 
1641
    return Success;
 
1642
 bail:
 
1643
    free(srcbits);
 
1644
    free(mskbits);
 
1645
    return rc;
 
1646
}
 
1647
 
 
1648
static int
 
1649
ProcRenderSetPictureTransform(ClientPtr client)
 
1650
{
 
1651
    REQUEST(xRenderSetPictureTransformReq);
 
1652
    PicturePtr pPicture;
 
1653
 
 
1654
    REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
 
1655
    VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
 
1656
    return SetPictureTransform(pPicture, (PictTransform *) &stuff->transform);
 
1657
}
 
1658
 
 
1659
static int
 
1660
ProcRenderQueryFilters(ClientPtr client)
 
1661
{
 
1662
    REQUEST(xRenderQueryFiltersReq);
 
1663
    DrawablePtr pDrawable;
 
1664
    xRenderQueryFiltersReply *reply;
 
1665
    int nbytesName;
 
1666
    int nnames;
 
1667
    ScreenPtr pScreen;
 
1668
    PictureScreenPtr ps;
 
1669
    int i, j, len, total_bytes, rc;
 
1670
    INT16 *aliases;
 
1671
    char *names;
 
1672
 
 
1673
    REQUEST_SIZE_MATCH(xRenderQueryFiltersReq);
 
1674
    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
 
1675
                           DixGetAttrAccess);
 
1676
    if (rc != Success)
 
1677
        return rc;
 
1678
 
 
1679
    pScreen = pDrawable->pScreen;
 
1680
    nbytesName = 0;
 
1681
    nnames = 0;
 
1682
    ps = GetPictureScreenIfSet(pScreen);
 
1683
    if (ps) {
 
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;
 
1689
    }
 
1690
    len = ((nnames + 1) >> 1) + bytes_to_int32(nbytesName);
 
1691
    total_bytes = sizeof(xRenderQueryFiltersReply) + (len << 2);
 
1692
    reply = (xRenderQueryFiltersReply *) calloc(1, total_bytes);
 
1693
    if (!reply)
 
1694
        return BadAlloc;
 
1695
    aliases = (INT16 *) (reply + 1);
 
1696
    names = (char *) (aliases + ((nnames + 1) & ~1));
 
1697
 
 
1698
    reply->type = X_Reply;
 
1699
    reply->sequenceNumber = client->sequence;
 
1700
    reply->length = len;
 
1701
    reply->numAliases = nnames;
 
1702
    reply->numFilters = nnames;
 
1703
    if (ps) {
 
1704
 
 
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)
 
1711
                    break;
 
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) {
 
1716
                        break;
 
1717
                    }
 
1718
                if (j == ps->nfilterAliases)
 
1719
                    j = FilterAliasNone;
 
1720
                else
 
1721
                    j = j + ps->nfilters;
 
1722
            }
 
1723
            aliases[i + ps->nfilters] = j;
 
1724
        }
 
1725
 
 
1726
        /* fill in filter names */
 
1727
        for (i = 0; i < ps->nfilters; i++) {
 
1728
            j = strlen(ps->filters[i].name);
 
1729
            *names++ = j;
 
1730
            memcpy(names, ps->filters[i].name, j);
 
1731
            names += j;
 
1732
        }
 
1733
 
 
1734
        /* fill in filter alias names */
 
1735
        for (i = 0; i < ps->nfilterAliases; i++) {
 
1736
            j = strlen(ps->filterAliases[i].alias);
 
1737
            *names++ = j;
 
1738
            memcpy(names, ps->filterAliases[i].alias, j);
 
1739
            names += j;
 
1740
        }
 
1741
    }
 
1742
 
 
1743
    if (client->swapped) {
 
1744
        for (i = 0; i < reply->numAliases; i++) {
 
1745
            swaps(&aliases[i]);
 
1746
        }
 
1747
        swaps(&reply->sequenceNumber);
 
1748
        swapl(&reply->length);
 
1749
        swapl(&reply->numAliases);
 
1750
        swapl(&reply->numFilters);
 
1751
    }
 
1752
    WriteToClient(client, total_bytes, reply);
 
1753
    free(reply);
 
1754
 
 
1755
    return Success;
 
1756
}
 
1757
 
 
1758
static int
 
1759
ProcRenderSetPictureFilter(ClientPtr client)
 
1760
{
 
1761
    REQUEST(xRenderSetPictureFilterReq);
 
1762
    PicturePtr pPicture;
 
1763
    int result;
 
1764
    xFixed *params;
 
1765
    int nparams;
 
1766
    char *name;
 
1767
 
 
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);
 
1774
    return result;
 
1775
}
 
1776
 
 
1777
static int
 
1778
ProcRenderCreateAnimCursor(ClientPtr client)
 
1779
{
 
1780
    REQUEST(xRenderCreateAnimCursorReq);
 
1781
    CursorPtr *cursors;
 
1782
    CARD32 *deltas;
 
1783
    CursorPtr pCursor;
 
1784
    int ncursor;
 
1785
    xAnimCursorElt *elt;
 
1786
    int i;
 
1787
    int ret;
 
1788
 
 
1789
    REQUEST_AT_LEAST_SIZE(xRenderCreateAnimCursorReq);
 
1790
    LEGAL_NEW_RESOURCE(stuff->cid, client);
 
1791
    if (client->req_len & 1)
 
1792
        return BadLength;
 
1793
    ncursor =
 
1794
        (client->req_len -
 
1795
         (bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1;
 
1796
    cursors = xallocarray(ncursor, sizeof(CursorPtr) + sizeof(CARD32));
 
1797
    if (!cursors)
 
1798
        return BadAlloc;
 
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) {
 
1805
            free(cursors);
 
1806
            return ret;
 
1807
        }
 
1808
        deltas[i] = elt->delay;
 
1809
        elt++;
 
1810
    }
 
1811
    ret = AnimCursorCreate(cursors, deltas, ncursor, &pCursor, client,
 
1812
                           stuff->cid);
 
1813
    free(cursors);
 
1814
    if (ret != Success)
 
1815
        return ret;
 
1816
 
 
1817
    if (AddResource(stuff->cid, RT_CURSOR, (void *) pCursor))
 
1818
        return Success;
 
1819
    return BadAlloc;
 
1820
}
 
1821
 
 
1822
static int
 
1823
ProcRenderAddTraps(ClientPtr client)
 
1824
{
 
1825
    int ntraps;
 
1826
    PicturePtr pPicture;
 
1827
 
 
1828
    REQUEST(xRenderAddTrapsReq);
 
1829
 
 
1830
    REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq);
 
1831
    VERIFY_PICTURE(pPicture, stuff->picture, client, DixWriteAccess);
 
1832
    if (!pPicture->pDrawable)
 
1833
        return BadDrawable;
 
1834
    ntraps = (client->req_len << 2) - sizeof(xRenderAddTrapsReq);
 
1835
    if (ntraps % sizeof(xTrap))
 
1836
        return BadLength;
 
1837
    ntraps /= sizeof(xTrap);
 
1838
    if (ntraps)
 
1839
        AddTraps(pPicture,
 
1840
                 stuff->xOff, stuff->yOff, ntraps, (xTrap *) &stuff[1]);
 
1841
    return Success;
 
1842
}
 
1843
 
 
1844
static int
 
1845
ProcRenderCreateSolidFill(ClientPtr client)
 
1846
{
 
1847
    PicturePtr pPicture;
 
1848
    int error = 0;
 
1849
 
 
1850
    REQUEST(xRenderCreateSolidFillReq);
 
1851
 
 
1852
    REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq);
 
1853
 
 
1854
    LEGAL_NEW_RESOURCE(stuff->pid, client);
 
1855
 
 
1856
    pPicture = CreateSolidPicture(stuff->pid, &stuff->color, &error);
 
1857
    if (!pPicture)
 
1858
        return 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)
 
1863
        return error;
 
1864
    if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
 
1865
        return BadAlloc;
 
1866
    return Success;
 
1867
}
 
1868
 
 
1869
static int
 
1870
ProcRenderCreateLinearGradient(ClientPtr client)
 
1871
{
 
1872
    PicturePtr pPicture;
 
1873
    int len;
 
1874
    int error = 0;
 
1875
    xFixed *stops;
 
1876
    xRenderColor *colors;
 
1877
 
 
1878
    REQUEST(xRenderCreateLinearGradientReq);
 
1879
 
 
1880
    REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq);
 
1881
 
 
1882
    LEGAL_NEW_RESOURCE(stuff->pid, client);
 
1883
 
 
1884
    len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
 
1885
    if (stuff->nStops > UINT32_MAX / (sizeof(xFixed) + sizeof(xRenderColor)))
 
1886
        return BadLength;
 
1887
    if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor)))
 
1888
        return BadLength;
 
1889
 
 
1890
    stops = (xFixed *) (stuff + 1);
 
1891
    colors = (xRenderColor *) (stops + stuff->nStops);
 
1892
 
 
1893
    pPicture = CreateLinearGradientPicture(stuff->pid, &stuff->p1, &stuff->p2,
 
1894
                                           stuff->nStops, stops, colors,
 
1895
                                           &error);
 
1896
    if (!pPicture)
 
1897
        return error;
 
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)
 
1902
        return error;
 
1903
    if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
 
1904
        return BadAlloc;
 
1905
    return Success;
 
1906
}
 
1907
 
 
1908
static int
 
1909
ProcRenderCreateRadialGradient(ClientPtr client)
 
1910
{
 
1911
    PicturePtr pPicture;
 
1912
    int len;
 
1913
    int error = 0;
 
1914
    xFixed *stops;
 
1915
    xRenderColor *colors;
 
1916
 
 
1917
    REQUEST(xRenderCreateRadialGradientReq);
 
1918
 
 
1919
    REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq);
 
1920
 
 
1921
    LEGAL_NEW_RESOURCE(stuff->pid, client);
 
1922
 
 
1923
    len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq);
 
1924
    if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor)))
 
1925
        return BadLength;
 
1926
 
 
1927
    stops = (xFixed *) (stuff + 1);
 
1928
    colors = (xRenderColor *) (stops + stuff->nStops);
 
1929
 
 
1930
    pPicture =
 
1931
        CreateRadialGradientPicture(stuff->pid, &stuff->inner, &stuff->outer,
 
1932
                                    stuff->inner_radius, stuff->outer_radius,
 
1933
                                    stuff->nStops, stops, colors, &error);
 
1934
    if (!pPicture)
 
1935
        return 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)
 
1940
        return error;
 
1941
    if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
 
1942
        return BadAlloc;
 
1943
    return Success;
 
1944
}
 
1945
 
 
1946
static int
 
1947
ProcRenderCreateConicalGradient(ClientPtr client)
 
1948
{
 
1949
    PicturePtr pPicture;
 
1950
    int len;
 
1951
    int error = 0;
 
1952
    xFixed *stops;
 
1953
    xRenderColor *colors;
 
1954
 
 
1955
    REQUEST(xRenderCreateConicalGradientReq);
 
1956
 
 
1957
    REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq);
 
1958
 
 
1959
    LEGAL_NEW_RESOURCE(stuff->pid, client);
 
1960
 
 
1961
    len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq);
 
1962
    if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor)))
 
1963
        return BadLength;
 
1964
 
 
1965
    stops = (xFixed *) (stuff + 1);
 
1966
    colors = (xRenderColor *) (stops + stuff->nStops);
 
1967
 
 
1968
    pPicture =
 
1969
        CreateConicalGradientPicture(stuff->pid, &stuff->center, stuff->angle,
 
1970
                                     stuff->nStops, stops, colors, &error);
 
1971
    if (!pPicture)
 
1972
        return 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)
 
1977
        return error;
 
1978
    if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
 
1979
        return BadAlloc;
 
1980
    return Success;
 
1981
}
 
1982
 
 
1983
static int
 
1984
ProcRenderDispatch(ClientPtr client)
 
1985
{
 
1986
    REQUEST(xReq);
 
1987
 
 
1988
    if (stuff->data < RenderNumberRequests)
 
1989
        return (*ProcRenderVector[stuff->data]) (client);
 
1990
    else
 
1991
        return BadRequest;
 
1992
}
 
1993
 
 
1994
static int
 
1995
SProcRenderQueryVersion(ClientPtr client)
 
1996
{
 
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);
 
2003
}
 
2004
 
 
2005
static int
 
2006
SProcRenderQueryPictFormats(ClientPtr client)
 
2007
{
 
2008
    REQUEST(xRenderQueryPictFormatsReq);
 
2009
    REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq);
 
2010
    swaps(&stuff->length);
 
2011
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2012
}
 
2013
 
 
2014
static int
 
2015
SProcRenderQueryPictIndexValues(ClientPtr client)
 
2016
{
 
2017
    REQUEST(xRenderQueryPictIndexValuesReq);
 
2018
    REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq);
 
2019
    swaps(&stuff->length);
 
2020
    swapl(&stuff->format);
 
2021
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2022
}
 
2023
 
 
2024
static int
 
2025
SProcRenderQueryDithers(ClientPtr client)
 
2026
{
 
2027
    return BadImplementation;
 
2028
}
 
2029
 
 
2030
static int
 
2031
SProcRenderCreatePicture(ClientPtr client)
 
2032
{
 
2033
    REQUEST(xRenderCreatePictureReq);
 
2034
    REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
 
2035
    swaps(&stuff->length);
 
2036
    swapl(&stuff->pid);
 
2037
    swapl(&stuff->drawable);
 
2038
    swapl(&stuff->format);
 
2039
    swapl(&stuff->mask);
 
2040
    SwapRestL(stuff);
 
2041
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2042
}
 
2043
 
 
2044
static int
 
2045
SProcRenderChangePicture(ClientPtr client)
 
2046
{
 
2047
    REQUEST(xRenderChangePictureReq);
 
2048
    REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
 
2049
    swaps(&stuff->length);
 
2050
    swapl(&stuff->picture);
 
2051
    swapl(&stuff->mask);
 
2052
    SwapRestL(stuff);
 
2053
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2054
}
 
2055
 
 
2056
static int
 
2057
SProcRenderSetPictureClipRectangles(ClientPtr client)
 
2058
{
 
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);
 
2065
    SwapRestS(stuff);
 
2066
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2067
}
 
2068
 
 
2069
static int
 
2070
SProcRenderFreePicture(ClientPtr client)
 
2071
{
 
2072
    REQUEST(xRenderFreePictureReq);
 
2073
    REQUEST_SIZE_MATCH(xRenderFreePictureReq);
 
2074
    swaps(&stuff->length);
 
2075
    swapl(&stuff->picture);
 
2076
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2077
}
 
2078
 
 
2079
static int
 
2080
SProcRenderComposite(ClientPtr client)
 
2081
{
 
2082
    REQUEST(xRenderCompositeReq);
 
2083
    REQUEST_SIZE_MATCH(xRenderCompositeReq);
 
2084
    swaps(&stuff->length);
 
2085
    swapl(&stuff->src);
 
2086
    swapl(&stuff->mask);
 
2087
    swapl(&stuff->dst);
 
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);
 
2097
}
 
2098
 
 
2099
static int
 
2100
SProcRenderScale(ClientPtr client)
 
2101
{
 
2102
    return BadImplementation;
 
2103
}
 
2104
 
 
2105
static int
 
2106
SProcRenderTrapezoids(ClientPtr client)
 
2107
{
 
2108
    REQUEST(xRenderTrapezoidsReq);
 
2109
 
 
2110
    REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq);
 
2111
    swaps(&stuff->length);
 
2112
    swapl(&stuff->src);
 
2113
    swapl(&stuff->dst);
 
2114
    swapl(&stuff->maskFormat);
 
2115
    swaps(&stuff->xSrc);
 
2116
    swaps(&stuff->ySrc);
 
2117
    SwapRestL(stuff);
 
2118
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2119
}
 
2120
 
 
2121
static int
 
2122
SProcRenderTriangles(ClientPtr client)
 
2123
{
 
2124
    REQUEST(xRenderTrianglesReq);
 
2125
 
 
2126
    REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
 
2127
    swaps(&stuff->length);
 
2128
    swapl(&stuff->src);
 
2129
    swapl(&stuff->dst);
 
2130
    swapl(&stuff->maskFormat);
 
2131
    swaps(&stuff->xSrc);
 
2132
    swaps(&stuff->ySrc);
 
2133
    SwapRestL(stuff);
 
2134
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2135
}
 
2136
 
 
2137
static int
 
2138
SProcRenderTriStrip(ClientPtr client)
 
2139
{
 
2140
    REQUEST(xRenderTriStripReq);
 
2141
 
 
2142
    REQUEST_AT_LEAST_SIZE(xRenderTriStripReq);
 
2143
    swaps(&stuff->length);
 
2144
    swapl(&stuff->src);
 
2145
    swapl(&stuff->dst);
 
2146
    swapl(&stuff->maskFormat);
 
2147
    swaps(&stuff->xSrc);
 
2148
    swaps(&stuff->ySrc);
 
2149
    SwapRestL(stuff);
 
2150
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2151
}
 
2152
 
 
2153
static int
 
2154
SProcRenderTriFan(ClientPtr client)
 
2155
{
 
2156
    REQUEST(xRenderTriFanReq);
 
2157
 
 
2158
    REQUEST_AT_LEAST_SIZE(xRenderTriFanReq);
 
2159
    swaps(&stuff->length);
 
2160
    swapl(&stuff->src);
 
2161
    swapl(&stuff->dst);
 
2162
    swapl(&stuff->maskFormat);
 
2163
    swaps(&stuff->xSrc);
 
2164
    swaps(&stuff->ySrc);
 
2165
    SwapRestL(stuff);
 
2166
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2167
}
 
2168
 
 
2169
static int
 
2170
SProcRenderColorTrapezoids(ClientPtr client)
 
2171
{
 
2172
    return BadImplementation;
 
2173
}
 
2174
 
 
2175
static int
 
2176
SProcRenderColorTriangles(ClientPtr client)
 
2177
{
 
2178
    return BadImplementation;
 
2179
}
 
2180
 
 
2181
static int
 
2182
SProcRenderTransform(ClientPtr client)
 
2183
{
 
2184
    return BadImplementation;
 
2185
}
 
2186
 
 
2187
static int
 
2188
SProcRenderCreateGlyphSet(ClientPtr client)
 
2189
{
 
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);
 
2196
}
 
2197
 
 
2198
static int
 
2199
SProcRenderReferenceGlyphSet(ClientPtr client)
 
2200
{
 
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);
 
2207
}
 
2208
 
 
2209
static int
 
2210
SProcRenderFreeGlyphSet(ClientPtr client)
 
2211
{
 
2212
    REQUEST(xRenderFreeGlyphSetReq);
 
2213
    REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
 
2214
    swaps(&stuff->length);
 
2215
    swapl(&stuff->glyphset);
 
2216
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2217
}
 
2218
 
 
2219
static int
 
2220
SProcRenderAddGlyphs(ClientPtr client)
 
2221
{
 
2222
    register int i;
 
2223
    CARD32 *gids;
 
2224
    void *end;
 
2225
    xGlyphInfo *gi;
 
2226
 
 
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)
 
2233
        return BadLength;
 
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)
 
2238
        return BadLength;
 
2239
    if ((char *) end - (char *) (gi + stuff->nglyphs) < 0)
 
2240
        return BadLength;
 
2241
    for (i = 0; i < stuff->nglyphs; i++) {
 
2242
        swapl(&gids[i]);
 
2243
        swaps(&gi[i].width);
 
2244
        swaps(&gi[i].height);
 
2245
        swaps(&gi[i].x);
 
2246
        swaps(&gi[i].y);
 
2247
        swaps(&gi[i].xOff);
 
2248
        swaps(&gi[i].yOff);
 
2249
    }
 
2250
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2251
}
 
2252
 
 
2253
static int
 
2254
SProcRenderAddGlyphsFromPicture(ClientPtr client)
 
2255
{
 
2256
    return BadImplementation;
 
2257
}
 
2258
 
 
2259
static int
 
2260
SProcRenderFreeGlyphs(ClientPtr client)
 
2261
{
 
2262
    REQUEST(xRenderFreeGlyphsReq);
 
2263
    REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
 
2264
    swaps(&stuff->length);
 
2265
    swapl(&stuff->glyphset);
 
2266
    SwapRestL(stuff);
 
2267
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2268
}
 
2269
 
 
2270
static int
 
2271
SProcRenderCompositeGlyphs(ClientPtr client)
 
2272
{
 
2273
    xGlyphElt *elt;
 
2274
    CARD8 *buffer;
 
2275
    CARD8 *end;
 
2276
    int space;
 
2277
    int i;
 
2278
    int size;
 
2279
 
 
2280
    REQUEST(xRenderCompositeGlyphsReq);
 
2281
    REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);
 
2282
 
 
2283
    switch (stuff->renderReqType) {
 
2284
    default:
 
2285
        size = 1;
 
2286
        break;
 
2287
    case X_RenderCompositeGlyphs16:
 
2288
        size = 2;
 
2289
        break;
 
2290
    case X_RenderCompositeGlyphs32:
 
2291
        size = 4;
 
2292
        break;
 
2293
    }
 
2294
 
 
2295
    swaps(&stuff->length);
 
2296
    swapl(&stuff->src);
 
2297
    swapl(&stuff->dst);
 
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);
 
2307
 
 
2308
        swaps(&elt->deltax);
 
2309
        swaps(&elt->deltay);
 
2310
 
 
2311
        i = elt->len;
 
2312
        if (i == 0xff) {
 
2313
            swapl((int *) buffer);
 
2314
            buffer += 4;
 
2315
        }
 
2316
        else {
 
2317
            space = size * i;
 
2318
            switch (size) {
 
2319
            case 1:
 
2320
                buffer += i;
 
2321
                break;
 
2322
            case 2:
 
2323
                while (i--) {
 
2324
                    swaps((short *) buffer);
 
2325
                    buffer += 2;
 
2326
                }
 
2327
                break;
 
2328
            case 4:
 
2329
                while (i--) {
 
2330
                    swapl((int *) buffer);
 
2331
                    buffer += 4;
 
2332
                }
 
2333
                break;
 
2334
            }
 
2335
            if (space & 3)
 
2336
                buffer += 4 - (space & 3);
 
2337
        }
 
2338
    }
 
2339
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2340
}
 
2341
 
 
2342
static int
 
2343
SProcRenderFillRectangles(ClientPtr client)
 
2344
{
 
2345
    REQUEST(xRenderFillRectanglesReq);
 
2346
 
 
2347
    REQUEST_AT_LEAST_SIZE(xRenderFillRectanglesReq);
 
2348
    swaps(&stuff->length);
 
2349
    swapl(&stuff->dst);
 
2350
    swaps(&stuff->color.red);
 
2351
    swaps(&stuff->color.green);
 
2352
    swaps(&stuff->color.blue);
 
2353
    swaps(&stuff->color.alpha);
 
2354
    SwapRestS(stuff);
 
2355
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2356
}
 
2357
 
 
2358
static int
 
2359
SProcRenderCreateCursor(ClientPtr client)
 
2360
{
 
2361
    REQUEST(xRenderCreateCursorReq);
 
2362
    REQUEST_SIZE_MATCH(xRenderCreateCursorReq);
 
2363
 
 
2364
    swaps(&stuff->length);
 
2365
    swapl(&stuff->cid);
 
2366
    swapl(&stuff->src);
 
2367
    swaps(&stuff->x);
 
2368
    swaps(&stuff->y);
 
2369
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2370
}
 
2371
 
 
2372
static int
 
2373
SProcRenderSetPictureTransform(ClientPtr client)
 
2374
{
 
2375
    REQUEST(xRenderSetPictureTransformReq);
 
2376
    REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
 
2377
 
 
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);
 
2390
}
 
2391
 
 
2392
static int
 
2393
SProcRenderQueryFilters(ClientPtr client)
 
2394
{
 
2395
    REQUEST(xRenderQueryFiltersReq);
 
2396
    REQUEST_SIZE_MATCH(xRenderQueryFiltersReq);
 
2397
 
 
2398
    swaps(&stuff->length);
 
2399
    swapl(&stuff->drawable);
 
2400
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2401
}
 
2402
 
 
2403
static int
 
2404
SProcRenderSetPictureFilter(ClientPtr client)
 
2405
{
 
2406
    REQUEST(xRenderSetPictureFilterReq);
 
2407
    REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq);
 
2408
 
 
2409
    swaps(&stuff->length);
 
2410
    swapl(&stuff->picture);
 
2411
    swaps(&stuff->nbytes);
 
2412
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2413
}
 
2414
 
 
2415
static int
 
2416
SProcRenderCreateAnimCursor(ClientPtr client)
 
2417
{
 
2418
    REQUEST(xRenderCreateAnimCursorReq);
 
2419
    REQUEST_AT_LEAST_SIZE(xRenderCreateAnimCursorReq);
 
2420
 
 
2421
    swaps(&stuff->length);
 
2422
    swapl(&stuff->cid);
 
2423
    SwapRestL(stuff);
 
2424
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2425
}
 
2426
 
 
2427
static int
 
2428
SProcRenderAddTraps(ClientPtr client)
 
2429
{
 
2430
    REQUEST(xRenderAddTrapsReq);
 
2431
    REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq);
 
2432
 
 
2433
    swaps(&stuff->length);
 
2434
    swapl(&stuff->picture);
 
2435
    swaps(&stuff->xOff);
 
2436
    swaps(&stuff->yOff);
 
2437
    SwapRestL(stuff);
 
2438
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2439
}
 
2440
 
 
2441
static int
 
2442
SProcRenderCreateSolidFill(ClientPtr client)
 
2443
{
 
2444
    REQUEST(xRenderCreateSolidFillReq);
 
2445
    REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq);
 
2446
 
 
2447
    swaps(&stuff->length);
 
2448
    swapl(&stuff->pid);
 
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);
 
2454
}
 
2455
 
 
2456
static void
 
2457
swapStops(void *stuff, int num)
 
2458
{
 
2459
    int i;
 
2460
    CARD32 *stops;
 
2461
    CARD16 *colors;
 
2462
 
 
2463
    stops = (CARD32 *) (stuff);
 
2464
    for (i = 0; i < num; ++i) {
 
2465
        swapl(stops);
 
2466
        ++stops;
 
2467
    }
 
2468
    colors = (CARD16 *) (stops);
 
2469
    for (i = 0; i < 4 * num; ++i) {
 
2470
        swaps(colors);
 
2471
        ++colors;
 
2472
    }
 
2473
}
 
2474
 
 
2475
static int
 
2476
SProcRenderCreateLinearGradient(ClientPtr client)
 
2477
{
 
2478
    int len;
 
2479
 
 
2480
    REQUEST(xRenderCreateLinearGradientReq);
 
2481
    REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq);
 
2482
 
 
2483
    swaps(&stuff->length);
 
2484
    swapl(&stuff->pid);
 
2485
    swapl(&stuff->p1.x);
 
2486
    swapl(&stuff->p1.y);
 
2487
    swapl(&stuff->p2.x);
 
2488
    swapl(&stuff->p2.y);
 
2489
    swapl(&stuff->nStops);
 
2490
 
 
2491
    len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
 
2492
    if (stuff->nStops > UINT32_MAX / (sizeof(xFixed) + sizeof(xRenderColor)))
 
2493
        return BadLength;
 
2494
    if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor)))
 
2495
        return BadLength;
 
2496
 
 
2497
    swapStops(stuff + 1, stuff->nStops);
 
2498
 
 
2499
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2500
}
 
2501
 
 
2502
static int
 
2503
SProcRenderCreateRadialGradient(ClientPtr client)
 
2504
{
 
2505
    int len;
 
2506
 
 
2507
    REQUEST(xRenderCreateRadialGradientReq);
 
2508
    REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq);
 
2509
 
 
2510
    swaps(&stuff->length);
 
2511
    swapl(&stuff->pid);
 
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);
 
2519
 
 
2520
    len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq);
 
2521
    if (stuff->nStops > UINT32_MAX / (sizeof(xFixed) + sizeof(xRenderColor)))
 
2522
        return BadLength;
 
2523
    if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor)))
 
2524
        return BadLength;
 
2525
 
 
2526
    swapStops(stuff + 1, stuff->nStops);
 
2527
 
 
2528
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2529
}
 
2530
 
 
2531
static int
 
2532
SProcRenderCreateConicalGradient(ClientPtr client)
 
2533
{
 
2534
    int len;
 
2535
 
 
2536
    REQUEST(xRenderCreateConicalGradientReq);
 
2537
    REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq);
 
2538
 
 
2539
    swaps(&stuff->length);
 
2540
    swapl(&stuff->pid);
 
2541
    swapl(&stuff->center.x);
 
2542
    swapl(&stuff->center.y);
 
2543
    swapl(&stuff->angle);
 
2544
    swapl(&stuff->nStops);
 
2545
 
 
2546
    len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq);
 
2547
    if (stuff->nStops > UINT32_MAX / (sizeof(xFixed) + sizeof(xRenderColor)))
 
2548
        return BadLength;
 
2549
    if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor)))
 
2550
        return BadLength;
 
2551
 
 
2552
    swapStops(stuff + 1, stuff->nStops);
 
2553
 
 
2554
    return (*ProcRenderVector[stuff->renderReqType]) (client);
 
2555
}
 
2556
 
 
2557
static int
 
2558
SProcRenderDispatch(ClientPtr client)
 
2559
{
 
2560
    REQUEST(xReq);
 
2561
 
 
2562
    if (stuff->data < RenderNumberRequests)
 
2563
        return (*SProcRenderVector[stuff->data]) (client);
 
2564
    else
 
2565
        return BadRequest;
 
2566
}
 
2567
 
 
2568
#ifdef PANORAMIX
 
2569
#define VERIFY_XIN_PICTURE(pPicture, pid, client, mode) {\
 
2570
    int rc = dixLookupResourceByType((void **)&(pPicture), pid,\
 
2571
                                     XRT_PICTURE, client, mode);\
 
2572
    if (rc != Success)\
 
2573
        return rc;\
 
2574
}
 
2575
 
 
2576
#define VERIFY_XIN_ALPHA(pPicture, pid, client, mode) {\
 
2577
    if (pid == None) \
 
2578
        pPicture = 0; \
 
2579
    else { \
 
2580
        VERIFY_XIN_PICTURE(pPicture, pid, client, mode); \
 
2581
    } \
 
2582
} \
 
2583
 
 
2584
int (*PanoramiXSaveRenderVector[RenderNumberRequests]) (ClientPtr);
 
2585
 
 
2586
static int
 
2587
PanoramiXRenderCreatePicture(ClientPtr client)
 
2588
{
 
2589
    REQUEST(xRenderCreatePictureReq);
 
2590
    PanoramiXRes *refDraw, *newPict;
 
2591
    int result, j;
 
2592
 
 
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))))
 
2599
        return BadAlloc;
 
2600
    newPict->type = XRT_PICTURE;
 
2601
    panoramix_setup_ids(newPict, client, stuff->pid);
 
2602
 
 
2603
    if (refDraw->type == XRT_WINDOW &&
 
2604
        stuff->drawable == screenInfo.screens[0]->root->drawable.id) {
 
2605
        newPict->u.pict.root = TRUE;
 
2606
    }
 
2607
    else
 
2608
        newPict->u.pict.root = FALSE;
 
2609
 
 
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)
 
2615
            break;
 
2616
    }
 
2617
 
 
2618
    if (result == Success)
 
2619
        AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
 
2620
    else
 
2621
        free(newPict);
 
2622
 
 
2623
    return result;
 
2624
}
 
2625
 
 
2626
static int
 
2627
PanoramiXRenderChangePicture(ClientPtr client)
 
2628
{
 
2629
    PanoramiXRes *pict;
 
2630
    int result = Success, j;
 
2631
 
 
2632
    REQUEST(xRenderChangePictureReq);
 
2633
 
 
2634
    REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
 
2635
 
 
2636
    VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess);
 
2637
 
 
2638
    FOR_NSCREENS_BACKWARD(j) {
 
2639
        stuff->picture = pict->info[j].id;
 
2640
        result = (*PanoramiXSaveRenderVector[X_RenderChangePicture]) (client);
 
2641
        if (result != Success)
 
2642
            break;
 
2643
    }
 
2644
 
 
2645
    return result;
 
2646
}
 
2647
 
 
2648
static int
 
2649
PanoramiXRenderSetPictureClipRectangles(ClientPtr client)
 
2650
{
 
2651
    REQUEST(xRenderSetPictureClipRectanglesReq);
 
2652
    int result = Success, j;
 
2653
    PanoramiXRes *pict;
 
2654
 
 
2655
    REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
 
2656
 
 
2657
    VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess);
 
2658
 
 
2659
    FOR_NSCREENS_BACKWARD(j) {
 
2660
        stuff->picture = pict->info[j].id;
 
2661
        result =
 
2662
            (*PanoramiXSaveRenderVector[X_RenderSetPictureClipRectangles])
 
2663
            (client);
 
2664
        if (result != Success)
 
2665
            break;
 
2666
    }
 
2667
 
 
2668
    return result;
 
2669
}
 
2670
 
 
2671
static int
 
2672
PanoramiXRenderSetPictureTransform(ClientPtr client)
 
2673
{
 
2674
    REQUEST(xRenderSetPictureTransformReq);
 
2675
    int result = Success, j;
 
2676
    PanoramiXRes *pict;
 
2677
 
 
2678
    REQUEST_AT_LEAST_SIZE(xRenderSetPictureTransformReq);
 
2679
 
 
2680
    VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess);
 
2681
 
 
2682
    FOR_NSCREENS_BACKWARD(j) {
 
2683
        stuff->picture = pict->info[j].id;
 
2684
        result =
 
2685
            (*PanoramiXSaveRenderVector[X_RenderSetPictureTransform]) (client);
 
2686
        if (result != Success)
 
2687
            break;
 
2688
    }
 
2689
 
 
2690
    return result;
 
2691
}
 
2692
 
 
2693
static int
 
2694
PanoramiXRenderSetPictureFilter(ClientPtr client)
 
2695
{
 
2696
    REQUEST(xRenderSetPictureFilterReq);
 
2697
    int result = Success, j;
 
2698
    PanoramiXRes *pict;
 
2699
 
 
2700
    REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq);
 
2701
 
 
2702
    VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess);
 
2703
 
 
2704
    FOR_NSCREENS_BACKWARD(j) {
 
2705
        stuff->picture = pict->info[j].id;
 
2706
        result =
 
2707
            (*PanoramiXSaveRenderVector[X_RenderSetPictureFilter]) (client);
 
2708
        if (result != Success)
 
2709
            break;
 
2710
    }
 
2711
 
 
2712
    return result;
 
2713
}
 
2714
 
 
2715
static int
 
2716
PanoramiXRenderFreePicture(ClientPtr client)
 
2717
{
 
2718
    PanoramiXRes *pict;
 
2719
    int result = Success, j;
 
2720
 
 
2721
    REQUEST(xRenderFreePictureReq);
 
2722
 
 
2723
    REQUEST_SIZE_MATCH(xRenderFreePictureReq);
 
2724
 
 
2725
    client->errorValue = stuff->picture;
 
2726
 
 
2727
    VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixDestroyAccess);
 
2728
 
 
2729
    FOR_NSCREENS_BACKWARD(j) {
 
2730
        stuff->picture = pict->info[j].id;
 
2731
        result = (*PanoramiXSaveRenderVector[X_RenderFreePicture]) (client);
 
2732
        if (result != Success)
 
2733
            break;
 
2734
    }
 
2735
 
 
2736
    /* Since ProcRenderFreePicture is using FreeResource, it will free
 
2737
       our resource for us on the last pass through the loop above */
 
2738
 
 
2739
    return result;
 
2740
}
 
2741
 
 
2742
static int
 
2743
PanoramiXRenderComposite(ClientPtr client)
 
2744
{
 
2745
    PanoramiXRes *src, *msk, *dst;
 
2746
    int result = Success, j;
 
2747
    xRenderCompositeReq orig;
 
2748
 
 
2749
    REQUEST(xRenderCompositeReq);
 
2750
 
 
2751
    REQUEST_SIZE_MATCH(xRenderCompositeReq);
 
2752
 
 
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);
 
2756
 
 
2757
    orig = *stuff;
 
2758
 
 
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;
 
2764
        }
 
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;
 
2769
        }
 
2770
        if (msk) {
 
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;
 
2775
            }
 
2776
        }
 
2777
        result = (*PanoramiXSaveRenderVector[X_RenderComposite]) (client);
 
2778
        if (result != Success)
 
2779
            break;
 
2780
    }
 
2781
 
 
2782
    return result;
 
2783
}
 
2784
 
 
2785
static int
 
2786
PanoramiXRenderCompositeGlyphs(ClientPtr client)
 
2787
{
 
2788
    PanoramiXRes *src, *dst;
 
2789
    int result = Success, j;
 
2790
 
 
2791
    REQUEST(xRenderCompositeGlyphsReq);
 
2792
    xGlyphElt origElt, *elt;
 
2793
    INT16 xSrc, ySrc;
 
2794
 
 
2795
    REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);
 
2796
    VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess);
 
2797
    VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess);
 
2798
 
 
2799
    if (client->req_len << 2 >= (sizeof(xRenderCompositeGlyphsReq) +
 
2800
                                 sizeof(xGlyphElt))) {
 
2801
        elt = (xGlyphElt *) (stuff + 1);
 
2802
        origElt = *elt;
 
2803
        xSrc = stuff->xSrc;
 
2804
        ySrc = stuff->ySrc;
 
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;
 
2810
            }
 
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;
 
2815
            }
 
2816
            result =
 
2817
                (*PanoramiXSaveRenderVector[stuff->renderReqType]) (client);
 
2818
            if (result != Success)
 
2819
                break;
 
2820
        }
 
2821
    }
 
2822
 
 
2823
    return result;
 
2824
}
 
2825
 
 
2826
static int
 
2827
PanoramiXRenderFillRectangles(ClientPtr client)
 
2828
{
 
2829
    PanoramiXRes *dst;
 
2830
    int result = Success, j;
 
2831
 
 
2832
    REQUEST(xRenderFillRectanglesReq);
 
2833
    char *extra;
 
2834
    int extra_len;
 
2835
 
 
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) {
 
2842
            if (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;
 
2847
 
 
2848
                if (x_off || y_off) {
 
2849
                    xRectangle *rects = (xRectangle *) (stuff + 1);
 
2850
                    int i = extra_len / sizeof(xRectangle);
 
2851
 
 
2852
                    while (i--) {
 
2853
                        rects->x -= x_off;
 
2854
                        rects->y -= y_off;
 
2855
                        rects++;
 
2856
                    }
 
2857
                }
 
2858
            }
 
2859
            stuff->dst = dst->info[j].id;
 
2860
            result =
 
2861
                (*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client);
 
2862
            if (result != Success)
 
2863
                break;
 
2864
        }
 
2865
        free(extra);
 
2866
    }
 
2867
 
 
2868
    return result;
 
2869
}
 
2870
 
 
2871
static int
 
2872
PanoramiXRenderTrapezoids(ClientPtr client)
 
2873
{
 
2874
    PanoramiXRes *src, *dst;
 
2875
    int result = Success, j;
 
2876
 
 
2877
    REQUEST(xRenderTrapezoidsReq);
 
2878
    char *extra;
 
2879
    int extra_len;
 
2880
 
 
2881
    REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq);
 
2882
 
 
2883
    VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess);
 
2884
    VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess);
 
2885
 
 
2886
    extra_len = (client->req_len << 2) - sizeof(xRenderTrapezoidsReq);
 
2887
 
 
2888
    if (extra_len && (extra = (char *) malloc(extra_len))) {
 
2889
        memcpy(extra, stuff + 1, extra_len);
 
2890
 
 
2891
        FOR_NSCREENS_FORWARD(j) {
 
2892
            if (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;
 
2897
 
 
2898
                if (x_off || y_off) {
 
2899
                    xTrapezoid *trap = (xTrapezoid *) (stuff + 1);
 
2900
                    int i = extra_len / sizeof(xTrapezoid);
 
2901
 
 
2902
                    while (i--) {
 
2903
                        trap->top -= y_off;
 
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;
 
2913
                        trap++;
 
2914
                    }
 
2915
                }
 
2916
            }
 
2917
 
 
2918
            stuff->src = src->info[j].id;
 
2919
            stuff->dst = dst->info[j].id;
 
2920
            result = (*PanoramiXSaveRenderVector[X_RenderTrapezoids]) (client);
 
2921
 
 
2922
            if (result != Success)
 
2923
                break;
 
2924
        }
 
2925
 
 
2926
        free(extra);
 
2927
    }
 
2928
 
 
2929
    return result;
 
2930
}
 
2931
 
 
2932
static int
 
2933
PanoramiXRenderTriangles(ClientPtr client)
 
2934
{
 
2935
    PanoramiXRes *src, *dst;
 
2936
    int result = Success, j;
 
2937
 
 
2938
    REQUEST(xRenderTrianglesReq);
 
2939
    char *extra;
 
2940
    int extra_len;
 
2941
 
 
2942
    REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
 
2943
 
 
2944
    VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess);
 
2945
    VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess);
 
2946
 
 
2947
    extra_len = (client->req_len << 2) - sizeof(xRenderTrianglesReq);
 
2948
 
 
2949
    if (extra_len && (extra = (char *) malloc(extra_len))) {
 
2950
        memcpy(extra, stuff + 1, extra_len);
 
2951
 
 
2952
        FOR_NSCREENS_FORWARD(j) {
 
2953
            if (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;
 
2958
 
 
2959
                if (x_off || y_off) {
 
2960
                    xTriangle *tri = (xTriangle *) (stuff + 1);
 
2961
                    int i = extra_len / sizeof(xTriangle);
 
2962
 
 
2963
                    while (i--) {
 
2964
                        tri->p1.x -= x_off;
 
2965
                        tri->p1.y -= y_off;
 
2966
                        tri->p2.x -= x_off;
 
2967
                        tri->p2.y -= y_off;
 
2968
                        tri->p3.x -= x_off;
 
2969
                        tri->p3.y -= y_off;
 
2970
                        tri++;
 
2971
                    }
 
2972
                }
 
2973
            }
 
2974
 
 
2975
            stuff->src = src->info[j].id;
 
2976
            stuff->dst = dst->info[j].id;
 
2977
            result = (*PanoramiXSaveRenderVector[X_RenderTriangles]) (client);
 
2978
 
 
2979
            if (result != Success)
 
2980
                break;
 
2981
        }
 
2982
 
 
2983
        free(extra);
 
2984
    }
 
2985
 
 
2986
    return result;
 
2987
}
 
2988
 
 
2989
static int
 
2990
PanoramiXRenderTriStrip(ClientPtr client)
 
2991
{
 
2992
    PanoramiXRes *src, *dst;
 
2993
    int result = Success, j;
 
2994
 
 
2995
    REQUEST(xRenderTriStripReq);
 
2996
    char *extra;
 
2997
    int extra_len;
 
2998
 
 
2999
    REQUEST_AT_LEAST_SIZE(xRenderTriStripReq);
 
3000
 
 
3001
    VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess);
 
3002
    VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess);
 
3003
 
 
3004
    extra_len = (client->req_len << 2) - sizeof(xRenderTriStripReq);
 
3005
 
 
3006
    if (extra_len && (extra = (char *) malloc(extra_len))) {
 
3007
        memcpy(extra, stuff + 1, extra_len);
 
3008
 
 
3009
        FOR_NSCREENS_FORWARD(j) {
 
3010
            if (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;
 
3015
 
 
3016
                if (x_off || y_off) {
 
3017
                    xPointFixed *fixed = (xPointFixed *) (stuff + 1);
 
3018
                    int i = extra_len / sizeof(xPointFixed);
 
3019
 
 
3020
                    while (i--) {
 
3021
                        fixed->x -= x_off;
 
3022
                        fixed->y -= y_off;
 
3023
                        fixed++;
 
3024
                    }
 
3025
                }
 
3026
            }
 
3027
 
 
3028
            stuff->src = src->info[j].id;
 
3029
            stuff->dst = dst->info[j].id;
 
3030
            result = (*PanoramiXSaveRenderVector[X_RenderTriStrip]) (client);
 
3031
 
 
3032
            if (result != Success)
 
3033
                break;
 
3034
        }
 
3035
 
 
3036
        free(extra);
 
3037
    }
 
3038
 
 
3039
    return result;
 
3040
}
 
3041
 
 
3042
static int
 
3043
PanoramiXRenderTriFan(ClientPtr client)
 
3044
{
 
3045
    PanoramiXRes *src, *dst;
 
3046
    int result = Success, j;
 
3047
 
 
3048
    REQUEST(xRenderTriFanReq);
 
3049
    char *extra;
 
3050
    int extra_len;
 
3051
 
 
3052
    REQUEST_AT_LEAST_SIZE(xRenderTriFanReq);
 
3053
 
 
3054
    VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess);
 
3055
    VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess);
 
3056
 
 
3057
    extra_len = (client->req_len << 2) - sizeof(xRenderTriFanReq);
 
3058
 
 
3059
    if (extra_len && (extra = (char *) malloc(extra_len))) {
 
3060
        memcpy(extra, stuff + 1, extra_len);
 
3061
 
 
3062
        FOR_NSCREENS_FORWARD(j) {
 
3063
            if (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;
 
3068
 
 
3069
                if (x_off || y_off) {
 
3070
                    xPointFixed *fixed = (xPointFixed *) (stuff + 1);
 
3071
                    int i = extra_len / sizeof(xPointFixed);
 
3072
 
 
3073
                    while (i--) {
 
3074
                        fixed->x -= x_off;
 
3075
                        fixed->y -= y_off;
 
3076
                        fixed++;
 
3077
                    }
 
3078
                }
 
3079
            }
 
3080
 
 
3081
            stuff->src = src->info[j].id;
 
3082
            stuff->dst = dst->info[j].id;
 
3083
            result = (*PanoramiXSaveRenderVector[X_RenderTriFan]) (client);
 
3084
 
 
3085
            if (result != Success)
 
3086
                break;
 
3087
        }
 
3088
 
 
3089
        free(extra);
 
3090
    }
 
3091
 
 
3092
    return result;
 
3093
}
 
3094
 
 
3095
static int
 
3096
PanoramiXRenderAddTraps(ClientPtr client)
 
3097
{
 
3098
    PanoramiXRes *picture;
 
3099
    int result = Success, j;
 
3100
 
 
3101
    REQUEST(xRenderAddTrapsReq);
 
3102
    char *extra;
 
3103
    int extra_len;
 
3104
    INT16 x_off, y_off;
 
3105
 
 
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) {
 
3114
            if (j)
 
3115
                memcpy(stuff + 1, extra, extra_len);
 
3116
            stuff->picture = picture->info[j].id;
 
3117
 
 
3118
            if (picture->u.pict.root) {
 
3119
                stuff->xOff = x_off + screenInfo.screens[j]->x;
 
3120
                stuff->yOff = y_off + screenInfo.screens[j]->y;
 
3121
            }
 
3122
            result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client);
 
3123
            if (result != Success)
 
3124
                break;
 
3125
        }
 
3126
        free(extra);
 
3127
    }
 
3128
 
 
3129
    return result;
 
3130
}
 
3131
 
 
3132
static int
 
3133
PanoramiXRenderCreateSolidFill(ClientPtr client)
 
3134
{
 
3135
    REQUEST(xRenderCreateSolidFillReq);
 
3136
    PanoramiXRes *newPict;
 
3137
    int result = Success, j;
 
3138
 
 
3139
    REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq);
 
3140
 
 
3141
    if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
 
3142
        return BadAlloc;
 
3143
 
 
3144
    newPict->type = XRT_PICTURE;
 
3145
    panoramix_setup_ids(newPict, client, stuff->pid);
 
3146
    newPict->u.pict.root = FALSE;
 
3147
 
 
3148
    FOR_NSCREENS_BACKWARD(j) {
 
3149
        stuff->pid = newPict->info[j].id;
 
3150
        result = (*PanoramiXSaveRenderVector[X_RenderCreateSolidFill]) (client);
 
3151
        if (result != Success)
 
3152
            break;
 
3153
    }
 
3154
 
 
3155
    if (result == Success)
 
3156
        AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
 
3157
    else
 
3158
        free(newPict);
 
3159
 
 
3160
    return result;
 
3161
}
 
3162
 
 
3163
static int
 
3164
PanoramiXRenderCreateLinearGradient(ClientPtr client)
 
3165
{
 
3166
    REQUEST(xRenderCreateLinearGradientReq);
 
3167
    PanoramiXRes *newPict;
 
3168
    int result = Success, j;
 
3169
 
 
3170
    REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq);
 
3171
 
 
3172
    if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
 
3173
        return BadAlloc;
 
3174
 
 
3175
    newPict->type = XRT_PICTURE;
 
3176
    panoramix_setup_ids(newPict, client, stuff->pid);
 
3177
    newPict->u.pict.root = FALSE;
 
3178
 
 
3179
    FOR_NSCREENS_BACKWARD(j) {
 
3180
        stuff->pid = newPict->info[j].id;
 
3181
        result =
 
3182
            (*PanoramiXSaveRenderVector[X_RenderCreateLinearGradient]) (client);
 
3183
        if (result != Success)
 
3184
            break;
 
3185
    }
 
3186
 
 
3187
    if (result == Success)
 
3188
        AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
 
3189
    else
 
3190
        free(newPict);
 
3191
 
 
3192
    return result;
 
3193
}
 
3194
 
 
3195
static int
 
3196
PanoramiXRenderCreateRadialGradient(ClientPtr client)
 
3197
{
 
3198
    REQUEST(xRenderCreateRadialGradientReq);
 
3199
    PanoramiXRes *newPict;
 
3200
    int result = Success, j;
 
3201
 
 
3202
    REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq);
 
3203
 
 
3204
    if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
 
3205
        return BadAlloc;
 
3206
 
 
3207
    newPict->type = XRT_PICTURE;
 
3208
    panoramix_setup_ids(newPict, client, stuff->pid);
 
3209
    newPict->u.pict.root = FALSE;
 
3210
 
 
3211
    FOR_NSCREENS_BACKWARD(j) {
 
3212
        stuff->pid = newPict->info[j].id;
 
3213
        result =
 
3214
            (*PanoramiXSaveRenderVector[X_RenderCreateRadialGradient]) (client);
 
3215
        if (result != Success)
 
3216
            break;
 
3217
    }
 
3218
 
 
3219
    if (result == Success)
 
3220
        AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
 
3221
    else
 
3222
        free(newPict);
 
3223
 
 
3224
    return result;
 
3225
}
 
3226
 
 
3227
static int
 
3228
PanoramiXRenderCreateConicalGradient(ClientPtr client)
 
3229
{
 
3230
    REQUEST(xRenderCreateConicalGradientReq);
 
3231
    PanoramiXRes *newPict;
 
3232
    int result = Success, j;
 
3233
 
 
3234
    REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq);
 
3235
 
 
3236
    if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
 
3237
        return BadAlloc;
 
3238
 
 
3239
    newPict->type = XRT_PICTURE;
 
3240
    panoramix_setup_ids(newPict, client, stuff->pid);
 
3241
    newPict->u.pict.root = FALSE;
 
3242
 
 
3243
    FOR_NSCREENS_BACKWARD(j) {
 
3244
        stuff->pid = newPict->info[j].id;
 
3245
        result =
 
3246
            (*PanoramiXSaveRenderVector[X_RenderCreateConicalGradient])
 
3247
            (client);
 
3248
        if (result != Success)
 
3249
            break;
 
3250
    }
 
3251
 
 
3252
    if (result == Success)
 
3253
        AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
 
3254
    else
 
3255
        free(newPict);
 
3256
 
 
3257
    return result;
 
3258
}
 
3259
 
 
3260
void
 
3261
PanoramiXRenderInit(void)
 
3262
{
 
3263
    int i;
 
3264
 
 
3265
    XRT_PICTURE = CreateNewResourceType(XineramaDeleteResource,
 
3266
                                        "XineramaPicture");
 
3267
    if (RenderErrBase)
 
3268
        SetResourceTypeErrorValue(XRT_PICTURE, RenderErrBase + BadPicture);
 
3269
    for (i = 0; i < RenderNumberRequests; i++)
 
3270
        PanoramiXSaveRenderVector[i] = ProcRenderVector[i];
 
3271
    /*
 
3272
     * Stuff in Xinerama aware request processing hooks
 
3273
     */
 
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;
 
3290
 
 
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;
 
3296
 
 
3297
    ProcRenderVector[X_RenderCreateSolidFill] = PanoramiXRenderCreateSolidFill;
 
3298
    ProcRenderVector[X_RenderCreateLinearGradient] =
 
3299
        PanoramiXRenderCreateLinearGradient;
 
3300
    ProcRenderVector[X_RenderCreateRadialGradient] =
 
3301
        PanoramiXRenderCreateRadialGradient;
 
3302
    ProcRenderVector[X_RenderCreateConicalGradient] =
 
3303
        PanoramiXRenderCreateConicalGradient;
 
3304
}
 
3305
 
 
3306
void
 
3307
PanoramiXRenderReset(void)
 
3308
{
 
3309
    int i;
 
3310
 
 
3311
    for (i = 0; i < RenderNumberRequests; i++)
 
3312
        ProcRenderVector[i] = PanoramiXSaveRenderVector[i];
 
3313
    RenderErrBase = 0;
 
3314
}
 
3315
 
 
3316
#endif                          /* PANORAMIX */