File: | render/render.c |
Location: | line 1490, column 16 |
Description: | Call to 'malloc' has an allocation size of 0 bytes |
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_H1 | |||
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 PANORAMIX1 | |||
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(36 +1)]) (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(36 +1)]) (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 ) (&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 , (&RenderClientPrivateKeyRec ))) ((RenderClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RenderClientPrivateKey(&RenderClientPrivateKeyRec ))) | |||
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)((RenderClientPtr)dixLookupPrivate(&(pClient)->devPrivates , (&RenderClientPrivateKeyRec ))); | |||
228 | ||||
229 | pRenderClient->major_version = 0; | |||
230 | pRenderClient->minor_version = 0; | |||
231 | } | |||
232 | ||||
233 | #ifdef PANORAMIX1 | |||
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"RENDER", 0, RenderNumberErrors(4 +1), | |||
253 | ProcRenderDispatch, SProcRenderDispatch, | |||
254 | NULL((void*)0), StandardMinorOpcode); | |||
255 | if (!extEntry) | |||
256 | return; | |||
257 | RenderErrBase = extEntry->errorBase; | |||
258 | #ifdef PANORAMIX1 | |||
259 | if (XRT_PICTURE) | |||
260 | SetResourceTypeErrorValue(XRT_PICTURE, RenderErrBase + BadPicture1); | |||
261 | #endif | |||
262 | SetResourceTypeErrorValue(PictureType, RenderErrBase + BadPicture1); | |||
263 | SetResourceTypeErrorValue(PictFormatType, RenderErrBase + BadPictFormat0); | |||
264 | SetResourceTypeErrorValue(GlyphSetType, RenderErrBase + BadGlyphSet3); | |||
265 | } | |||
266 | ||||
267 | static int | |||
268 | ProcRenderQueryVersion(ClientPtr client) | |||
269 | { | |||
270 | RenderClientPtr pRenderClient = GetRenderClient(client)((RenderClientPtr)dixLookupPrivate(&(client)->devPrivates , (&RenderClientPrivateKeyRec ))); | |||
271 | xRenderQueryVersionReply rep = { | |||
272 | .type = X_Reply1, | |||
273 | .sequenceNumber = client->sequence, | |||
274 | .length = 0 | |||
275 | }; | |||
276 | ||||
277 | REQUEST(xRenderQueryVersionReq)xRenderQueryVersionReq *stuff = (xRenderQueryVersionReq *)client ->requestBuffer; | |||
278 | ||||
279 | REQUEST_SIZE_MATCH(xRenderQueryVersionReq)if ((sizeof(xRenderQueryVersionReq) >> 2) != client-> req_len) return(16); | |||
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_VERSION0 * 1000 + SERVER_RENDER_MINOR_VERSION11)) { | |||
286 | rep.majorVersion = stuff->majorVersion; | |||
287 | rep.minorVersion = stuff->minorVersion; | |||
288 | } | |||
289 | else { | |||
290 | rep.majorVersion = SERVER_RENDER_MAJOR_VERSION0; | |||
291 | rep.minorVersion = SERVER_RENDER_MINOR_VERSION11; | |||
292 | } | |||
293 | ||||
294 | if (client->swapped) { | |||
295 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
296 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
297 | swapl(&rep.majorVersion)do { if (sizeof(*(&rep.majorVersion)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.majorVersion) & 3) && ((uintptr_t)(&rep.majorVersion) & 3) == 0) *(&rep.majorVersion) = lswapl(*(&rep.majorVersion )); else swap_uint32((uint32_t *)(&rep.majorVersion)); } while (0); | |||
298 | swapl(&rep.minorVersion)do { if (sizeof(*(&rep.minorVersion)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.minorVersion) & 3) && ((uintptr_t)(&rep.minorVersion) & 3) == 0) *(&rep.minorVersion) = lswapl(*(&rep.minorVersion )); else swap_uint32((uint32_t *)(&rep.minorVersion)); } while (0); | |||
299 | } | |||
300 | WriteToClient(client, sizeof(xRenderQueryVersionReply), &rep); | |||
301 | return Success0; | |||
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)((RenderClientPtr)dixLookupPrivate(&(client)->devPrivates , (&RenderClientPrivateKeyRec ))); | |||
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)if ((sizeof(xRenderQueryPictFormatsReq) >> 2) != client ->req_len) return(16); | |||
345 | ||||
346 | #ifdef PANORAMIX1 | |||
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)(dixPrivateKeyRegistered((&PictureScreenPrivateKeyRec)) ? ((PictureScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates , (&PictureScreenPrivateKeyRec))) : ((void*)0)); | |||
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 BadAlloc11; | |||
385 | reply->type = X_Reply1; | |||
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)(dixPrivateKeyRegistered((&PictureScreenPrivateKeyRec)) ? ((PictureScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates , (&PictureScreenPrivateKeyRec))) : ((void*)0)); | |||
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 == PictTypeIndexed0 && | |||
414 | pFormat->index.pColormap) | |||
415 | pictForm->colormap = pFormat->index.pColormap->mid; | |||
416 | else | |||
417 | pictForm->colormap = None0L; | |||
418 | if (client->swapped) { | |||
419 | swapl(&pictForm->id)do { if (sizeof(*(&pictForm->id)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&pictForm->id) & 3) && ((uintptr_t)(&pictForm->id) & 3) == 0) *(&pictForm->id) = lswapl(*(&pictForm->id)) ; else swap_uint32((uint32_t *)(&pictForm->id)); } while (0); | |||
420 | swaps(&pictForm->direct.red)do { if (sizeof(*(&pictForm->direct.red)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictForm->direct .red) & 1) && ((uintptr_t)(&pictForm->direct .red) & 1) == 0) *(&pictForm->direct.red) = lswaps (*(&pictForm->direct.red)); else swap_uint16((uint16_t *)(&pictForm->direct.red)); } while (0); | |||
421 | swaps(&pictForm->direct.redMask)do { if (sizeof(*(&pictForm->direct.redMask)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictForm->direct .redMask) & 1) && ((uintptr_t)(&pictForm-> direct.redMask) & 1) == 0) *(&pictForm->direct.redMask ) = lswaps(*(&pictForm->direct.redMask)); else swap_uint16 ((uint16_t *)(&pictForm->direct.redMask)); } while (0); | |||
422 | swaps(&pictForm->direct.green)do { if (sizeof(*(&pictForm->direct.green)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictForm->direct .green) & 1) && ((uintptr_t)(&pictForm->direct .green) & 1) == 0) *(&pictForm->direct.green) = lswaps (*(&pictForm->direct.green)); else swap_uint16((uint16_t *)(&pictForm->direct.green)); } while (0); | |||
423 | swaps(&pictForm->direct.greenMask)do { if (sizeof(*(&pictForm->direct.greenMask)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictForm->direct .greenMask) & 1) && ((uintptr_t)(&pictForm-> direct.greenMask) & 1) == 0) *(&pictForm->direct.greenMask ) = lswaps(*(&pictForm->direct.greenMask)); else swap_uint16 ((uint16_t *)(&pictForm->direct.greenMask)); } while ( 0); | |||
424 | swaps(&pictForm->direct.blue)do { if (sizeof(*(&pictForm->direct.blue)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictForm->direct .blue) & 1) && ((uintptr_t)(&pictForm->direct .blue) & 1) == 0) *(&pictForm->direct.blue) = lswaps (*(&pictForm->direct.blue)); else swap_uint16((uint16_t *)(&pictForm->direct.blue)); } while (0); | |||
425 | swaps(&pictForm->direct.blueMask)do { if (sizeof(*(&pictForm->direct.blueMask)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictForm->direct .blueMask) & 1) && ((uintptr_t)(&pictForm-> direct.blueMask) & 1) == 0) *(&pictForm->direct.blueMask ) = lswaps(*(&pictForm->direct.blueMask)); else swap_uint16 ((uint16_t *)(&pictForm->direct.blueMask)); } while (0 ); | |||
426 | swaps(&pictForm->direct.alpha)do { if (sizeof(*(&pictForm->direct.alpha)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictForm->direct .alpha) & 1) && ((uintptr_t)(&pictForm->direct .alpha) & 1) == 0) *(&pictForm->direct.alpha) = lswaps (*(&pictForm->direct.alpha)); else swap_uint16((uint16_t *)(&pictForm->direct.alpha)); } while (0); | |||
427 | swaps(&pictForm->direct.alphaMask)do { if (sizeof(*(&pictForm->direct.alphaMask)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictForm->direct .alphaMask) & 1) && ((uintptr_t)(&pictForm-> direct.alphaMask) & 1) == 0) *(&pictForm->direct.alphaMask ) = lswaps(*(&pictForm->direct.alphaMask)); else swap_uint16 ((uint16_t *)(&pictForm->direct.alphaMask)); } while ( 0); | |||
428 | swapl(&pictForm->colormap)do { if (sizeof(*(&pictForm->colormap)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictForm->colormap ) & 3) && ((uintptr_t)(&pictForm->colormap ) & 3) == 0) *(&pictForm->colormap) = lswapl(*(& pictForm->colormap)); else swap_uint32((uint32_t *)(&pictForm ->colormap)); } while (0); | |||
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)do { if (sizeof(*(&pictVisual->visual)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictVisual-> visual) & 3) && ((uintptr_t)(&pictVisual-> visual) & 3) == 0) *(&pictVisual->visual) = lswapl (*(&pictVisual->visual)); else swap_uint32((uint32_t * )(&pictVisual->visual)); } while (0); | |||
454 | swapl(&pictVisual->format)do { if (sizeof(*(&pictVisual->format)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictVisual-> format) & 3) && ((uintptr_t)(&pictVisual-> format) & 3) == 0) *(&pictVisual->format) = lswapl (*(&pictVisual->format)); else swap_uint32((uint32_t * )(&pictVisual->format)); } while (0); | |||
455 | } | |||
456 | pictVisual++; | |||
457 | nvisual++; | |||
458 | } | |||
459 | } | |||
460 | pictDepth->depth = pDepth->depth; | |||
461 | pictDepth->nPictVisuals = nvisual; | |||
462 | if (client->swapped) { | |||
463 | swaps(&pictDepth->nPictVisuals)do { if (sizeof(*(&pictDepth->nPictVisuals)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictDepth->nPictVisuals ) & 1) && ((uintptr_t)(&pictDepth->nPictVisuals ) & 1) == 0) *(&pictDepth->nPictVisuals) = lswaps( *(&pictDepth->nPictVisuals)); else swap_uint16((uint16_t *)(&pictDepth->nPictVisuals)); } while (0); | |||
464 | } | |||
465 | ndepth++; | |||
466 | pictDepth = (xPictDepth *) pictVisual; | |||
467 | } | |||
468 | pictScreen->nDepth = ndepth; | |||
469 | ps = GetPictureScreenIfSet(pScreen)(dixPrivateKeyRegistered((&PictureScreenPrivateKeyRec)) ? ((PictureScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates , (&PictureScreenPrivateKeyRec))) : ((void*)0)); | |||
470 | if (ps) | |||
471 | pictScreen->fallback = ps->fallback->id; | |||
472 | else | |||
473 | pictScreen->fallback = 0; | |||
474 | if (client->swapped) { | |||
475 | swapl(&pictScreen->nDepth)do { if (sizeof(*(&pictScreen->nDepth)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictScreen-> nDepth) & 3) && ((uintptr_t)(&pictScreen-> nDepth) & 3) == 0) *(&pictScreen->nDepth) = lswapl (*(&pictScreen->nDepth)); else swap_uint32((uint32_t * )(&pictScreen->nDepth)); } while (0); | |||
476 | swapl(&pictScreen->fallback)do { if (sizeof(*(&pictScreen->fallback)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pictScreen-> fallback) & 3) && ((uintptr_t)(&pictScreen-> fallback) & 3) == 0) *(&pictScreen->fallback) = lswapl (*(&pictScreen->fallback)); else swap_uint32((uint32_t *)(&pictScreen->fallback)); } while (0); | |||
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)(dixPrivateKeyRegistered((&PictureScreenPrivateKeyRec)) ? ((PictureScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates , (&PictureScreenPrivateKeyRec))) : ((void*)0)); | |||
485 | if (ps) | |||
486 | *pictSubpixel = ps->subpixel; | |||
487 | else | |||
488 | *pictSubpixel = SubPixelUnknown0; | |||
489 | if (client->swapped) { | |||
490 | swapl(pictSubpixel)do { if (sizeof(*(pictSubpixel)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(pictSubpixel) & 3) && ((uintptr_t)(pictSubpixel ) & 3) == 0) *(pictSubpixel) = lswapl(*(pictSubpixel)); else swap_uint32((uint32_t *)(pictSubpixel)); } while (0); | |||
491 | } | |||
492 | ++pictSubpixel; | |||
493 | } | |||
494 | ||||
495 | if (client->swapped) { | |||
496 | swaps(&reply->sequenceNumber)do { if (sizeof(*(&reply->sequenceNumber)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&reply->sequenceNumber ) & 1) && ((uintptr_t)(&reply->sequenceNumber ) & 1) == 0) *(&reply->sequenceNumber) = lswaps(*( &reply->sequenceNumber)); else swap_uint16((uint16_t * )(&reply->sequenceNumber)); } while (0); | |||
497 | swapl(&reply->length)do { if (sizeof(*(&reply->length)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&reply->length) & 3) && ((uintptr_t)(&reply->length) & 3) == 0) *(&reply->length) = lswapl(*(&reply->length )); else swap_uint32((uint32_t *)(&reply->length)); } while (0); | |||
498 | swapl(&reply->numFormats)do { if (sizeof(*(&reply->numFormats)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&reply->numFormats ) & 3) && ((uintptr_t)(&reply->numFormats) & 3) == 0) *(&reply->numFormats) = lswapl(*(& reply->numFormats)); else swap_uint32((uint32_t *)(&reply ->numFormats)); } while (0); | |||
499 | swapl(&reply->numScreens)do { if (sizeof(*(&reply->numScreens)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&reply->numScreens ) & 3) && ((uintptr_t)(&reply->numScreens) & 3) == 0) *(&reply->numScreens) = lswapl(*(& reply->numScreens)); else swap_uint32((uint32_t *)(&reply ->numScreens)); } while (0); | |||
500 | swapl(&reply->numDepths)do { if (sizeof(*(&reply->numDepths)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&reply->numDepths ) & 3) && ((uintptr_t)(&reply->numDepths) & 3) == 0) *(&reply->numDepths) = lswapl(*(&reply-> numDepths)); else swap_uint32((uint32_t *)(&reply->numDepths )); } while (0); | |||
501 | swapl(&reply->numVisuals)do { if (sizeof(*(&reply->numVisuals)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&reply->numVisuals ) & 3) && ((uintptr_t)(&reply->numVisuals) & 3) == 0) *(&reply->numVisuals) = lswapl(*(& reply->numVisuals)); else swap_uint32((uint32_t *)(&reply ->numVisuals)); } while (0); | |||
502 | swapl(&reply->numSubpixel)do { if (sizeof(*(&reply->numSubpixel)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&reply->numSubpixel ) & 3) && ((uintptr_t)(&reply->numSubpixel ) & 3) == 0) *(&reply->numSubpixel) = lswapl(*(& reply->numSubpixel)); else swap_uint32((uint32_t *)(&reply ->numSubpixel)); } while (0); | |||
503 | } | |||
504 | WriteToClient(client, rlength, reply); | |||
505 | free(reply); | |||
506 | return Success0; | |||
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)xRenderQueryPictIndexValuesReq *stuff = (xRenderQueryPictIndexValuesReq *)client->requestBuffer; | |||
518 | xRenderQueryPictIndexValuesReply *reply; | |||
519 | xIndexValue *values; | |||
520 | ||||
521 | REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq)if ((sizeof(xRenderQueryPictIndexValuesReq) >> 2) > client ->req_len ) return(16); | |||
522 | ||||
523 | rc = dixLookupResourceByType((void **) &pFormat, stuff->format, | |||
524 | PictFormatType, client, DixReadAccess(1<<0)); | |||
525 | if (rc != Success0) | |||
526 | return rc; | |||
527 | ||||
528 | if (pFormat->type != PictTypeIndexed0) { | |||
529 | client->errorValue = stuff->format; | |||
530 | return BadMatch8; | |||
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 BadAlloc11; | |||
538 | ||||
539 | reply->type = X_Reply1; | |||
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))__builtin___memcpy_chk (reply + 1, pFormat->index.pValues, num * sizeof(xIndexValue), __builtin_object_size (reply + 1, 0)); | |||
547 | ||||
548 | if (client->swapped) { | |||
549 | for (i = 0; i < num; i++) { | |||
550 | swapl(&values[i].pixel)do { if (sizeof(*(&values[i].pixel)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&values[i].pixel) & 3) && ((uintptr_t)(&values[i].pixel) & 3) == 0) *(&values[i].pixel) = lswapl(*(&values[i].pixel)) ; else swap_uint32((uint32_t *)(&values[i].pixel)); } while (0); | |||
551 | swaps(&values[i].red)do { if (sizeof(*(&values[i].red)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&values[i].red) & 1 ) && ((uintptr_t)(&values[i].red) & 1) == 0) * (&values[i].red) = lswaps(*(&values[i].red)); else swap_uint16 ((uint16_t *)(&values[i].red)); } while (0); | |||
552 | swaps(&values[i].green)do { if (sizeof(*(&values[i].green)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&values[i].green) & 1) && ((uintptr_t)(&values[i].green) & 1) == 0) *(&values[i].green) = lswaps(*(&values[i].green)) ; else swap_uint16((uint16_t *)(&values[i].green)); } while (0); | |||
553 | swaps(&values[i].blue)do { if (sizeof(*(&values[i].blue)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&values[i].blue) & 1) && ((uintptr_t)(&values[i].blue) & 1) == 0 ) *(&values[i].blue) = lswaps(*(&values[i].blue)); else swap_uint16((uint16_t *)(&values[i].blue)); } while (0); | |||
554 | swaps(&values[i].alpha)do { if (sizeof(*(&values[i].alpha)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&values[i].alpha) & 1) && ((uintptr_t)(&values[i].alpha) & 1) == 0) *(&values[i].alpha) = lswaps(*(&values[i].alpha)) ; else swap_uint16((uint16_t *)(&values[i].alpha)); } while (0); | |||
555 | } | |||
556 | swaps(&reply->sequenceNumber)do { if (sizeof(*(&reply->sequenceNumber)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&reply->sequenceNumber ) & 1) && ((uintptr_t)(&reply->sequenceNumber ) & 1) == 0) *(&reply->sequenceNumber) = lswaps(*( &reply->sequenceNumber)); else swap_uint16((uint16_t * )(&reply->sequenceNumber)); } while (0); | |||
557 | swapl(&reply->length)do { if (sizeof(*(&reply->length)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&reply->length) & 3) && ((uintptr_t)(&reply->length) & 3) == 0) *(&reply->length) = lswapl(*(&reply->length )); else swap_uint32((uint32_t *)(&reply->length)); } while (0); | |||
558 | swapl(&reply->numIndexValues)do { if (sizeof(*(&reply->numIndexValues)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&reply->numIndexValues ) & 3) && ((uintptr_t)(&reply->numIndexValues ) & 3) == 0) *(&reply->numIndexValues) = lswapl(*( &reply->numIndexValues)); else swap_uint32((uint32_t * )(&reply->numIndexValues)); } while (0); | |||
559 | } | |||
560 | ||||
561 | WriteToClient(client, rlength, reply); | |||
562 | free(reply); | |||
563 | return Success0; | |||
564 | } | |||
565 | ||||
566 | static int | |||
567 | ProcRenderQueryDithers(ClientPtr client) | |||
568 | { | |||
569 | return BadImplementation17; | |||
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)xRenderCreatePictureReq *stuff = (xRenderCreatePictureReq *)client ->requestBuffer; | |||
581 | ||||
582 | REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq)if ((sizeof(xRenderCreatePictureReq) >> 2) > client-> req_len ) return(16); | |||
583 | ||||
584 | LEGAL_NEW_RESOURCE(stuff->pid, client)if (!LegalNewID(stuff->pid,client)) { client->errorValue = stuff->pid; return 14; }; | |||
585 | rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, | |||
586 | DixReadAccess(1<<0) | DixAddAccess(1<<12)); | |||
587 | if (rc != Success0) | |||
588 | return rc; | |||
589 | ||||
590 | rc = dixLookupResourceByType((void **) &pFormat, stuff->format, | |||
591 | PictFormatType, client, DixReadAccess(1<<0)); | |||
592 | if (rc != Success0) | |||
593 | return rc; | |||
594 | ||||
595 | if (pFormat->depth != pDrawable->depth) | |||
596 | return BadMatch8; | |||
597 | len = client->req_len - bytes_to_int32(sizeof(xRenderCreatePictureReq)); | |||
598 | if (Ones(stuff->mask) != len) | |||
599 | return BadLength16; | |||
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 (!AddResourceDarwin_X_AddResource(stuff->pid, PictureType, (void *) pPicture)) | |||
608 | return BadAlloc11; | |||
609 | return Success0; | |||
610 | } | |||
611 | ||||
612 | static int | |||
613 | ProcRenderChangePicture(ClientPtr client) | |||
614 | { | |||
615 | PicturePtr pPicture; | |||
616 | ||||
617 | REQUEST(xRenderChangePictureReq)xRenderChangePictureReq *stuff = (xRenderChangePictureReq *)client ->requestBuffer; | |||
618 | int len; | |||
619 | ||||
620 | REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq)if ((sizeof(xRenderChangePictureReq) >> 2) > client-> req_len ) return(16); | |||
621 | VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess){ int tmprc = dixLookupResourceByType((void *)&(pPicture) , stuff->picture, PictureType, client, (1<<5)); if ( tmprc != 0) return tmprc;}; | |||
622 | ||||
623 | len = client->req_len - bytes_to_int32(sizeof(xRenderChangePictureReq)); | |||
624 | if (Ones(stuff->mask) != len) | |||
625 | return BadLength16; | |||
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)xRenderSetPictureClipRectanglesReq *stuff = (xRenderSetPictureClipRectanglesReq *)client->requestBuffer; | |||
635 | PicturePtr pPicture; | |||
636 | int nr; | |||
637 | ||||
638 | REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq)if ((sizeof(xRenderSetPictureClipRectanglesReq) >> 2) > client->req_len ) return(16); | |||
639 | VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess){ int tmprc = dixLookupResourceByType((void *)&(pPicture) , stuff->picture, PictureType, client, (1<<5)); if ( tmprc != 0) return tmprc;}; | |||
640 | if (!pPicture->pDrawable) | |||
641 | return RenderErrBase + BadPicture1; | |||
642 | ||||
643 | nr = (client->req_len << 2) - sizeof(xRenderSetPictureClipRectanglesReq); | |||
644 | if (nr & 4) | |||
645 | return BadLength16; | |||
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)xRenderFreePictureReq *stuff = (xRenderFreePictureReq *)client ->requestBuffer; | |||
658 | ||||
659 | REQUEST_SIZE_MATCH(xRenderFreePictureReq)if ((sizeof(xRenderFreePictureReq) >> 2) != client-> req_len) return(16); | |||
660 | ||||
661 | VERIFY_PICTURE(pPicture, stuff->picture, client, DixDestroyAccess){ int tmprc = dixLookupResourceByType((void *)&(pPicture) , stuff->picture, PictureType, client, (1<<2)); if ( tmprc != 0) return tmprc;}; | |||
662 | FreeResource(stuff->picture, RT_NONE((RESTYPE)0)); | |||
663 | return Success0; | |||
664 | } | |||
665 | ||||
666 | static Bool | |||
667 | PictOpValid(CARD8 op) | |||
668 | { | |||
669 | if ( /*PictOpMinimum <= op && */ op <= PictOpMaximum13) | |||
670 | return TRUE1; | |||
671 | if (PictOpDisjointMinimum0x10 <= op && op <= PictOpDisjointMaximum0x1b) | |||
672 | return TRUE1; | |||
673 | if (PictOpConjointMinimum0x20 <= op && op <= PictOpConjointMaximum0x2b) | |||
674 | return TRUE1; | |||
675 | if (PictOpBlendMinimum0x30 <= op && op <= PictOpBlendMaximum0x3e) | |||
676 | return TRUE1; | |||
677 | return FALSE0; | |||
678 | } | |||
679 | ||||
680 | static int | |||
681 | ProcRenderComposite(ClientPtr client) | |||
682 | { | |||
683 | PicturePtr pSrc, pMask, pDst; | |||
684 | ||||
685 | REQUEST(xRenderCompositeReq)xRenderCompositeReq *stuff = (xRenderCompositeReq *)client-> requestBuffer; | |||
686 | ||||
687 | REQUEST_SIZE_MATCH(xRenderCompositeReq)if ((sizeof(xRenderCompositeReq) >> 2) != client->req_len ) return(16); | |||
688 | if (!PictOpValid(stuff->op)) { | |||
689 | client->errorValue = stuff->op; | |||
690 | return BadValue2; | |||
691 | } | |||
692 | VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess){ int tmprc = dixLookupResourceByType((void *)&(pDst), stuff ->dst, PictureType, client, (1<<1)); if (tmprc != 0) return tmprc;}; | |||
693 | if (!pDst->pDrawable) | |||
694 | return BadDrawable9; | |||
695 | VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess){ int tmprc = dixLookupResourceByType((void *)&(pSrc), stuff ->src, PictureType, client, (1<<0)); if (tmprc != 0) return tmprc;}; | |||
696 | VERIFY_ALPHA(pMask, stuff->mask, client, DixReadAccess){ if (stuff->mask == 0L) pMask = 0; else { { int tmprc = dixLookupResourceByType ((void *)&(pMask), stuff->mask, PictureType, client, ( 1<<0)); if (tmprc != 0) return tmprc;}; } }; | |||
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 BadMatch8; | |||
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 Success0; | |||
718 | } | |||
719 | ||||
720 | static int | |||
721 | ProcRenderScale(ClientPtr client) | |||
722 | { | |||
723 | return BadImplementation17; | |||
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)xRenderTrapezoidsReq *stuff = (xRenderTrapezoidsReq *)client-> requestBuffer; | |||
734 | ||||
735 | REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq)if ((sizeof(xRenderTrapezoidsReq) >> 2) > client-> req_len ) return(16); | |||
736 | if (!PictOpValid(stuff->op)) { | |||
737 | client->errorValue = stuff->op; | |||
738 | return BadValue2; | |||
739 | } | |||
740 | VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess){ int tmprc = dixLookupResourceByType((void *)&(pSrc), stuff ->src, PictureType, client, (1<<0)); if (tmprc != 0) return tmprc;}; | |||
741 | VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess){ int tmprc = dixLookupResourceByType((void *)&(pDst), stuff ->dst, PictureType, client, (1<<1)); if (tmprc != 0) return tmprc;}; | |||
742 | if (!pDst->pDrawable) | |||
743 | return BadDrawable9; | |||
744 | if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) | |||
745 | return BadMatch8; | |||
746 | if (stuff->maskFormat) { | |||
747 | rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat, | |||
748 | PictFormatType, client, DixReadAccess(1<<0)); | |||
749 | if (rc != Success0) | |||
750 | return rc; | |||
751 | } | |||
752 | else | |||
753 | pFormat = 0; | |||
754 | ntraps = (client->req_len << 2) - sizeof(xRenderTrapezoidsReq); | |||
755 | if (ntraps % sizeof(xTrapezoid)) | |||
756 | return BadLength16; | |||
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 Success0; | |||
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)xRenderTrianglesReq *stuff = (xRenderTrianglesReq *)client-> requestBuffer; | |||
773 | ||||
774 | REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq)if ((sizeof(xRenderTrianglesReq) >> 2) > client-> req_len ) return(16); | |||
775 | if (!PictOpValid(stuff->op)) { | |||
776 | client->errorValue = stuff->op; | |||
777 | return BadValue2; | |||
778 | } | |||
779 | VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess){ int tmprc = dixLookupResourceByType((void *)&(pSrc), stuff ->src, PictureType, client, (1<<0)); if (tmprc != 0) return tmprc;}; | |||
780 | VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess){ int tmprc = dixLookupResourceByType((void *)&(pDst), stuff ->dst, PictureType, client, (1<<1)); if (tmprc != 0) return tmprc;}; | |||
781 | if (!pDst->pDrawable) | |||
782 | return BadDrawable9; | |||
783 | if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) | |||
784 | return BadMatch8; | |||
785 | if (stuff->maskFormat) { | |||
786 | rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat, | |||
787 | PictFormatType, client, DixReadAccess(1<<0)); | |||
788 | if (rc != Success0) | |||
789 | return rc; | |||
790 | } | |||
791 | else | |||
792 | pFormat = 0; | |||
793 | ntris = (client->req_len << 2) - sizeof(xRenderTrianglesReq); | |||
794 | if (ntris % sizeof(xTriangle)) | |||
795 | return BadLength16; | |||
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 Success0; | |||
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)xRenderTrianglesReq *stuff = (xRenderTrianglesReq *)client-> requestBuffer; | |||
812 | ||||
813 | REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq)if ((sizeof(xRenderTrianglesReq) >> 2) > client-> req_len ) return(16); | |||
814 | if (!PictOpValid(stuff->op)) { | |||
815 | client->errorValue = stuff->op; | |||
816 | return BadValue2; | |||
817 | } | |||
818 | VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess){ int tmprc = dixLookupResourceByType((void *)&(pSrc), stuff ->src, PictureType, client, (1<<0)); if (tmprc != 0) return tmprc;}; | |||
819 | VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess){ int tmprc = dixLookupResourceByType((void *)&(pDst), stuff ->dst, PictureType, client, (1<<1)); if (tmprc != 0) return tmprc;}; | |||
820 | if (!pDst->pDrawable) | |||
821 | return BadDrawable9; | |||
822 | if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) | |||
823 | return BadMatch8; | |||
824 | if (stuff->maskFormat) { | |||
825 | rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat, | |||
826 | PictFormatType, client, DixReadAccess(1<<0)); | |||
827 | if (rc != Success0) | |||
828 | return rc; | |||
829 | } | |||
830 | else | |||
831 | pFormat = 0; | |||
832 | npoints = ((client->req_len << 2) - sizeof(xRenderTriStripReq)); | |||
833 | if (npoints & 4) | |||
834 | return BadLength16; | |||
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 Success0; | |||
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)xRenderTrianglesReq *stuff = (xRenderTrianglesReq *)client-> requestBuffer; | |||
851 | ||||
852 | REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq)if ((sizeof(xRenderTrianglesReq) >> 2) > client-> req_len ) return(16); | |||
853 | if (!PictOpValid(stuff->op)) { | |||
854 | client->errorValue = stuff->op; | |||
855 | return BadValue2; | |||
856 | } | |||
857 | VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess){ int tmprc = dixLookupResourceByType((void *)&(pSrc), stuff ->src, PictureType, client, (1<<0)); if (tmprc != 0) return tmprc;}; | |||
858 | VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess){ int tmprc = dixLookupResourceByType((void *)&(pDst), stuff ->dst, PictureType, client, (1<<1)); if (tmprc != 0) return tmprc;}; | |||
859 | if (!pDst->pDrawable) | |||
860 | return BadDrawable9; | |||
861 | if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) | |||
862 | return BadMatch8; | |||
863 | if (stuff->maskFormat) { | |||
864 | rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat, | |||
865 | PictFormatType, client, DixReadAccess(1<<0)); | |||
866 | if (rc != Success0) | |||
867 | return rc; | |||
868 | } | |||
869 | else | |||
870 | pFormat = 0; | |||
871 | npoints = ((client->req_len << 2) - sizeof(xRenderTriStripReq)); | |||
872 | if (npoints & 4) | |||
873 | return BadLength16; | |||
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 Success0; | |||
880 | } | |||
881 | ||||
882 | static int | |||
883 | ProcRenderColorTrapezoids(ClientPtr client) | |||
884 | { | |||
885 | return BadImplementation17; | |||
886 | } | |||
887 | ||||
888 | static int | |||
889 | ProcRenderColorTriangles(ClientPtr client) | |||
890 | { | |||
891 | return BadImplementation17; | |||
892 | } | |||
893 | ||||
894 | static int | |||
895 | ProcRenderTransform(ClientPtr client) | |||
896 | { | |||
897 | return BadImplementation17; | |||
898 | } | |||
899 | ||||
900 | static int | |||
901 | ProcRenderCreateGlyphSet(ClientPtr client) | |||
902 | { | |||
903 | GlyphSetPtr glyphSet; | |||
904 | PictFormatPtr format; | |||
905 | int rc, f; | |||
906 | ||||
907 | REQUEST(xRenderCreateGlyphSetReq)xRenderCreateGlyphSetReq *stuff = (xRenderCreateGlyphSetReq * )client->requestBuffer; | |||
908 | ||||
909 | REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq)if ((sizeof(xRenderCreateGlyphSetReq) >> 2) != client-> req_len) return(16); | |||
910 | ||||
911 | LEGAL_NEW_RESOURCE(stuff->gsid, client)if (!LegalNewID(stuff->gsid,client)) { client->errorValue = stuff->gsid; return 14; }; | |||
912 | rc = dixLookupResourceByType((void **) &format, stuff->format, | |||
913 | PictFormatType, client, DixReadAccess(1<<0)); | |||
914 | if (rc != Success0) | |||
915 | return rc; | |||
916 | ||||
917 | switch (format->depth) { | |||
918 | case 1: | |||
919 | f = GlyphFormat10; | |||
920 | break; | |||
921 | case 4: | |||
922 | f = GlyphFormat41; | |||
923 | break; | |||
924 | case 8: | |||
925 | f = GlyphFormat82; | |||
926 | break; | |||
927 | case 16: | |||
928 | f = GlyphFormat163; | |||
929 | break; | |||
930 | case 32: | |||
931 | f = GlyphFormat324; | |||
932 | break; | |||
933 | default: | |||
934 | return BadMatch8; | |||
935 | } | |||
936 | if (format->type != PictTypeDirect1) | |||
937 | return BadMatch8; | |||
938 | glyphSet = AllocateGlyphSet(f, format); | |||
939 | if (!glyphSet) | |||
940 | return BadAlloc11; | |||
941 | /* security creation/labeling check */ | |||
942 | rc = XaceHook(XACE_RESOURCE_ACCESS2, client, stuff->gsid, GlyphSetType, | |||
943 | glyphSet, RT_NONE((RESTYPE)0), NULL((void*)0), DixCreateAccess(1<<3)); | |||
944 | if (rc != Success0) | |||
945 | return rc; | |||
946 | if (!AddResourceDarwin_X_AddResource(stuff->gsid, GlyphSetType, (void *) glyphSet)) | |||
947 | return BadAlloc11; | |||
948 | return Success0; | |||
949 | } | |||
950 | ||||
951 | static int | |||
952 | ProcRenderReferenceGlyphSet(ClientPtr client) | |||
953 | { | |||
954 | GlyphSetPtr glyphSet; | |||
955 | int rc; | |||
956 | ||||
957 | REQUEST(xRenderReferenceGlyphSetReq)xRenderReferenceGlyphSetReq *stuff = (xRenderReferenceGlyphSetReq *)client->requestBuffer; | |||
958 | ||||
959 | REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq)if ((sizeof(xRenderReferenceGlyphSetReq) >> 2) != client ->req_len) return(16); | |||
960 | ||||
961 | LEGAL_NEW_RESOURCE(stuff->gsid, client)if (!LegalNewID(stuff->gsid,client)) { client->errorValue = stuff->gsid; return 14; }; | |||
962 | ||||
963 | rc = dixLookupResourceByType((void **) &glyphSet, stuff->existing, | |||
964 | GlyphSetType, client, DixGetAttrAccess(1<<4)); | |||
965 | if (rc != Success0) { | |||
966 | client->errorValue = stuff->existing; | |||
967 | return rc; | |||
968 | } | |||
969 | glyphSet->refcnt++; | |||
970 | if (!AddResourceDarwin_X_AddResource(stuff->gsid, GlyphSetType, (void *) glyphSet)) | |||
971 | return BadAlloc11; | |||
972 | return Success0; | |||
973 | } | |||
974 | ||||
975 | #define NLOCALDELTA64 64 | |||
976 | #define NLOCALGLYPH256 256 | |||
977 | ||||
978 | static int | |||
979 | ProcRenderFreeGlyphSet(ClientPtr client) | |||
980 | { | |||
981 | GlyphSetPtr glyphSet; | |||
982 | int rc; | |||
983 | ||||
984 | REQUEST(xRenderFreeGlyphSetReq)xRenderFreeGlyphSetReq *stuff = (xRenderFreeGlyphSetReq *)client ->requestBuffer; | |||
985 | ||||
986 | REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq)if ((sizeof(xRenderFreeGlyphSetReq) >> 2) != client-> req_len) return(16); | |||
987 | rc = dixLookupResourceByType((void **) &glyphSet, stuff->glyphset, | |||
988 | GlyphSetType, client, DixDestroyAccess(1<<2)); | |||
989 | if (rc != Success0) { | |||
990 | client->errorValue = stuff->glyphset; | |||
991 | return rc; | |||
992 | } | |||
993 | FreeResource(stuff->glyphset, RT_NONE((RESTYPE)0)); | |||
994 | return Success0; | |||
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)((((f) >> 12) & 0x0f) != 0 && (((f) ) & 0xfff) != 0) (PICT_FORMAT_A(f)(((f) >> 12) & 0x0f) != 0 && PICT_FORMAT_RGB(f)(((f) ) & 0xfff) != 0) | |||
1005 | ||||
1006 | static int | |||
1007 | ProcRenderAddGlyphs(ClientPtr client) | |||
1008 | { | |||
1009 | GlyphSetPtr glyphSet; | |||
1010 | ||||
1011 | REQUEST(xRenderAddGlyphsReq)xRenderAddGlyphsReq *stuff = (xRenderAddGlyphsReq *)client-> requestBuffer; | |||
1012 | GlyphNewRec glyphsLocal[NLOCALGLYPH256]; | |||
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((void*)0), pDst = NULL((void*)0); | |||
1022 | PixmapPtr pSrcPix = NULL((void*)0), pDstPix = NULL((void*)0); | |||
1023 | CARD32 component_alpha; | |||
1024 | ||||
1025 | REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq)if ((sizeof(xRenderAddGlyphsReq) >> 2) > client-> req_len ) return(16); | |||
1026 | err = | |||
1027 | dixLookupResourceByType((void **) &glyphSet, stuff->glyphset, | |||
1028 | GlyphSetType, client, DixAddAccess(1<<12)); | |||
1029 | if (err != Success0) { | |||
1030 | client->errorValue = stuff->glyphset; | |||
1031 | return err; | |||
1032 | } | |||
1033 | ||||
1034 | err = BadAlloc11; | |||
1035 | nglyphs = stuff->nglyphs; | |||
1036 | if (nglyphs > UINT32_MAX4294967295U / sizeof(GlyphNewRec)) | |||
1037 | return BadAlloc11; | |||
1038 | ||||
1039 | component_alpha = NeedsComponent(glyphSet->format->format)((((glyphSet->format->format) >> 12) & 0x0f) != 0 && (((glyphSet->format->format) ) & 0xfff ) != 0); | |||
1040 | ||||
1041 | if (nglyphs <= NLOCALGLYPH256) { | |||
1042 | memset(glyphsLocal, 0, sizeof(glyphsLocal))__builtin___memset_chk (glyphsLocal, 0, sizeof(glyphsLocal), __builtin_object_size (glyphsLocal, 0)); | |||
1043 | glyphsBase = glyphsLocal; | |||
1044 | } | |||
1045 | else { | |||
1046 | glyphsBase = (GlyphNewPtr) calloc(nglyphs, sizeof(GlyphNewRec)); | |||
1047 | if (!glyphsBase) | |||
1048 | return BadAlloc11; | |||
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 = BadLength16; | |||
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)((PixmapWidthPaddingInfo[glyphSet->format->depth].notPower2 ? (((int)(gi[i].width) * PixmapWidthPaddingInfo[glyphSet-> format->depth].bytesPerPixel + PixmapWidthPaddingInfo[glyphSet ->format->depth].bytesPerPixel) >> PixmapWidthPaddingInfo [glyphSet->format->depth].padBytesLog2) : ((int)((gi[i] .width) + PixmapWidthPaddingInfo[glyphSet->format->depth ].padRoundUp) >> PixmapWidthPaddingInfo[glyphSet->format ->depth].padPixelsLog2)) << PixmapWidthPaddingInfo[glyphSet ->format->depth].padBytesLog2); | |||
1075 | ||||
1076 | if (gi[i].height && | |||
1077 | padded_width > (UINT32_MAX4294967295U - 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((GlyphPtr) 1)) { | |||
1091 | glyph_new->found = TRUE1; | |||
1092 | } | |||
1093 | else { | |||
1094 | GlyphPtr glyph; | |||
1095 | ||||
1096 | glyph_new->found = FALSE0; | |||
1097 | glyph_new->glyph = glyph = AllocateGlyph(&gi[i], glyphSet->fdepth); | |||
1098 | if (!glyph) { | |||
1099 | err = BadAlloc11; | |||
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 = BadAlloc11; | |||
1120 | goto bail; | |||
1121 | } | |||
1122 | ||||
1123 | pSrc = CreatePicture(0, &pSrcPix->drawable, | |||
1124 | glyphSet->format, 0, NULL((void*)0), | |||
1125 | serverClient, &error); | |||
1126 | if (!pSrc) { | |||
1127 | err = BadAlloc11; | |||
1128 | goto bail; | |||
1129 | } | |||
1130 | ||||
1131 | pDstPix = (pScreen->CreatePixmap) (pScreen, | |||
1132 | width, height, depth, | |||
1133 | CREATE_PIXMAP_USAGE_GLYPH_PICTURE3); | |||
1134 | ||||
1135 | if (!pDstPix) { | |||
1136 | err = BadAlloc11; | |||
1137 | goto bail; | |||
1138 | } | |||
1139 | ||||
1140 | pDst = CreatePicture(0, &pDstPix->drawable, | |||
1141 | glyphSet->format, | |||
1142 | CPComponentAlpha(1 << 12), &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((void*)0); | |||
1150 | ||||
1151 | if (!pDst) { | |||
1152 | err = BadAlloc11; | |||
1153 | goto bail; | |||
1154 | } | |||
1155 | ||||
1156 | CompositePicture(PictOpSrc1, | |||
1157 | pSrc, | |||
1158 | None0L, pDst, 0, 0, 0, 0, 0, 0, width, height); | |||
1159 | ||||
1160 | FreePicture((void *) pSrc, 0); | |||
1161 | pSrc = NULL((void*)0); | |||
1162 | FreeScratchPixmapHeader(pSrcPix); | |||
1163 | pSrcPix = NULL((void*)0); | |||
1164 | } | |||
1165 | ||||
1166 | memcpy(glyph_new->glyph->sha1, glyph_new->sha1, 20)__builtin___memcpy_chk (glyph_new->glyph->sha1, glyph_new ->sha1, 20, __builtin_object_size (glyph_new->glyph-> sha1, 0)); | |||
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 = BadLength16; | |||
1178 | goto bail; | |||
1179 | } | |||
1180 | if (!ResizeGlyphSet(glyphSet, nglyphs)) { | |||
1181 | err = BadAlloc11; | |||
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 Success0; | |||
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 BadImplementation17; | |||
1207 | } | |||
1208 | ||||
1209 | static int | |||
1210 | ProcRenderFreeGlyphs(ClientPtr client) | |||
1211 | { | |||
1212 | REQUEST(xRenderFreeGlyphsReq)xRenderFreeGlyphsReq *stuff = (xRenderFreeGlyphsReq *)client-> requestBuffer; | |||
1213 | GlyphSetPtr glyphSet; | |||
1214 | int rc, nglyph; | |||
1215 | CARD32 *gids; | |||
1216 | CARD32 glyph; | |||
1217 | ||||
1218 | REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq)if ((sizeof(xRenderFreeGlyphsReq) >> 2) > client-> req_len ) return(16); | |||
1219 | rc = dixLookupResourceByType((void **) &glyphSet, stuff->glyphset, | |||
1220 | GlyphSetType, client, DixRemoveAccess(1<<13)); | |||
1221 | if (rc != Success0) { | |||
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 + BadGlyph4; | |||
1233 | } | |||
1234 | } | |||
1235 | return Success0; | |||
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[NLOCALDELTA64]; | |||
1246 | GlyphListPtr lists, listsBase; | |||
1247 | GlyphPtr glyphsLocal[NLOCALGLYPH256]; | |||
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)xRenderCompositeGlyphsReq *stuff = (xRenderCompositeGlyphsReq *)client->requestBuffer; | |||
1259 | ||||
1260 | REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq)if ((sizeof(xRenderCompositeGlyphsReq) >> 2) > client ->req_len ) return(16); | |||
1261 | ||||
1262 | switch (stuff->renderReqType) { | |||
1263 | default: | |||
1264 | size = 1; | |||
1265 | break; | |||
1266 | case X_RenderCompositeGlyphs1624: | |||
1267 | size = 2; | |||
1268 | break; | |||
1269 | case X_RenderCompositeGlyphs3225: | |||
1270 | size = 4; | |||
1271 | break; | |||
1272 | } | |||
1273 | ||||
1274 | if (!PictOpValid(stuff->op)) { | |||
1275 | client->errorValue = stuff->op; | |||
1276 | return BadValue2; | |||
1277 | } | |||
1278 | VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess){ int tmprc = dixLookupResourceByType((void *)&(pSrc), stuff ->src, PictureType, client, (1<<0)); if (tmprc != 0) return tmprc;}; | |||
1279 | VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess){ int tmprc = dixLookupResourceByType((void *)&(pDst), stuff ->dst, PictureType, client, (1<<1)); if (tmprc != 0) return tmprc;}; | |||
1280 | if (!pDst->pDrawable) | |||
1281 | return BadDrawable9; | |||
1282 | if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) | |||
1283 | return BadMatch8; | |||
1284 | if (stuff->maskFormat) { | |||
1285 | rc = dixLookupResourceByType((void **) &pFormat, stuff->maskFormat, | |||
1286 | PictFormatType, client, DixReadAccess(1<<0)); | |||
1287 | if (rc != Success0) | |||
1288 | return rc; | |||
1289 | } | |||
1290 | else | |||
1291 | pFormat = 0; | |||
1292 | ||||
1293 | rc = dixLookupResourceByType((void **) &glyphSet, stuff->glyphset, | |||
1294 | GlyphSetType, client, DixUseAccess(1<<24)); | |||
1295 | if (rc != Success0) | |||
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 <= NLOCALGLYPH256) | |||
1319 | glyphsBase = glyphsLocal; | |||
1320 | else { | |||
1321 | glyphsBase = (GlyphPtr *) malloc(nglyph * sizeof(GlyphPtr)); | |||
1322 | if (!glyphsBase) | |||
1323 | return BadAlloc11; | |||
1324 | } | |||
1325 | if (nlist <= NLOCALDELTA64) | |||
1326 | listsBase = listsLocal; | |||
1327 | else { | |||
1328 | listsBase = (GlyphListPtr) malloc(nlist * sizeof(GlyphListRec)); | |||
1329 | if (!listsBase) { | |||
1330 | rc = BadAlloc11; | |||
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))__builtin___memcpy_chk (&gs, buffer, sizeof(GlyphSet), __builtin_object_size (&gs, 0)); | |||
1344 | rc = dixLookupResourceByType((void **) &glyphSet, gs, | |||
1345 | GlyphSetType, client, | |||
1346 | DixUseAccess(1<<24)); | |||
1347 | if (rc != Success0) | |||
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 = BadLength16; | |||
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 = Success0; | |||
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)xRenderFillRectanglesReq *stuff = (xRenderFillRectanglesReq * )client->requestBuffer; | |||
1412 | ||||
1413 | REQUEST_AT_LEAST_SIZE(xRenderFillRectanglesReq)if ((sizeof(xRenderFillRectanglesReq) >> 2) > client ->req_len ) return(16); | |||
1414 | if (!PictOpValid(stuff->op)) { | |||
1415 | client->errorValue = stuff->op; | |||
1416 | return BadValue2; | |||
1417 | } | |||
1418 | VERIFY_PICTURE(pDst, stuff->dst, client, DixWriteAccess){ int tmprc = dixLookupResourceByType((void *)&(pDst), stuff ->dst, PictureType, client, (1<<1)); if (tmprc != 0) return tmprc;}; | |||
1419 | if (!pDst->pDrawable) | |||
1420 | return BadDrawable9; | |||
1421 | ||||
1422 | things = (client->req_len << 2) - sizeof(xRenderFillRectanglesReq); | |||
1423 | if (things & 4) | |||
1424 | return BadLength16; | |||
1425 | things >>= 3; | |||
1426 | ||||
1427 | CompositeRects(stuff->op, | |||
1428 | pDst, &stuff->color, things, (xRectangle *) &stuff[1]); | |||
1429 | ||||
1430 | return Success0; | |||
1431 | } | |||
1432 | ||||
1433 | static void | |||
1434 | RenderSetBit(unsigned char *line, int x, int bit) | |||
1435 | { | |||
1436 | unsigned char mask; | |||
1437 | ||||
1438 | if (screenInfo.bitmapBitOrder == LSBFirst0) | |||
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_DIM2 2 | |||
1451 | ||||
1452 | static CARD32 orderedDither[DITHER_DIM2][DITHER_DIM2] = { | |||
1453 | {1, 3,}, | |||
1454 | {4, 2,}, | |||
1455 | }; | |||
1456 | ||||
1457 | #define DITHER_SIZE((sizeof orderedDither / sizeof orderedDither[0][0]) + 1) ((sizeof orderedDither / sizeof orderedDither[0][0]) + 1) | |||
1458 | ||||
1459 | static int | |||
1460 | ProcRenderCreateCursor(ClientPtr client) | |||
1461 | { | |||
1462 | REQUEST(xRenderCreateCursorReq)xRenderCreateCursorReq *stuff = (xRenderCreateCursorReq *)client ->requestBuffer; | |||
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)if ((sizeof(xRenderCreateCursorReq) >> 2) != client-> req_len) return(16); | |||
1478 | LEGAL_NEW_RESOURCE(stuff->cid, client)if (!LegalNewID(stuff->cid,client)) { client->errorValue = stuff->cid; return 14; }; | |||
1479 | ||||
1480 | VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess){ int tmprc = dixLookupResourceByType((void *)&(pSrc), stuff ->src, PictureType, client, (1<<0)); if (tmprc != 0) return tmprc;}; | |||
1481 | if (!pSrc->pDrawable) | |||
| ||||
1482 | return BadDrawable9; | |||
1483 | pScreen = pSrc->pDrawable->pScreen; | |||
1484 | width = pSrc->pDrawable->width; | |||
1485 | height = pSrc->pDrawable->height; | |||
1486 | if (height && width > UINT32_MAX4294967295U / (height * sizeof(CARD32))) | |||
1487 | return BadAlloc11; | |||
1488 | if (stuff->x > width || stuff->y > height) | |||
1489 | return BadMatch8; | |||
1490 | argbbits = malloc(width * height * sizeof(CARD32)); | |||
| ||||
1491 | if (!argbbits) | |||
1492 | return BadAlloc11; | |||
1493 | ||||
1494 | stride = BitmapBytePad(width)(((int)((width) + 32 - 1) >> 5) << 2); | |||
1495 | nbytes_mono = stride * height; | |||
1496 | srcbits = calloc(1, nbytes_mono); | |||
1497 | if (!srcbits) { | |||
1498 | free(argbbits); | |||
1499 | return BadAlloc11; | |||
1500 | } | |||
1501 | mskbits = calloc(1, nbytes_mono); | |||
1502 | if (!mskbits) { | |||
1503 | free(argbbits); | |||
1504 | free(srcbits); | |||
1505 | return BadAlloc11; | |||
1506 | } | |||
1507 | ||||
1508 | if (pSrc->format == PICT_a8r8g8b8) { | |||
1509 | (*pScreen->GetImage) (pSrc->pDrawable, | |||
1510 | 0, 0, width, height, ZPixmap2, | |||
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 BadImplementation17; | |||
1525 | } | |||
1526 | pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 32, | |||
1527 | CREATE_PIXMAP_USAGE_SCRATCH1); | |||
1528 | if (!pPixmap) { | |||
1529 | free(argbbits); | |||
1530 | free(srcbits); | |||
1531 | free(mskbits); | |||
1532 | return BadAlloc11; | |||
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(PictOpSrc1, | |||
1544 | pSrc, 0, pPicture, 0, 0, 0, 0, 0, 0, width, height); | |||
1545 | (*pScreen->GetImage) (pPicture->pDrawable, | |||
1546 | 0, 0, width, height, ZPixmap2, | |||
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((sizeof orderedDither / sizeof orderedDither[0][0]) + 1) + 127) / 255; | |||
1595 | CARD32 i = ((CvtR8G8B8toY15(p)(((((p) >> 16) & 0xff) * 153 + (((p) >> 8) & 0xff) * 301 + (((p) ) & 0xff) * 58) >> 2) >> 7) * DITHER_SIZE((sizeof orderedDither / sizeof orderedDither[0][0]) + 1) + 127) / 255; | |||
1596 | CARD32 d = | |||
1597 | orderedDither[y & (DITHER_DIM2 - 1)][x & (DITHER_DIM2 - 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) (((p) >> (s)) & 0xff) | |||
1620 | #define GetColor(p,s)((((p) >> (s)) & 0xff) | ((((p) >> (s)) & 0xff) << 8)) (GetByte(p,s)(((p) >> (s)) & 0xff) | (GetByte(p,s)(((p) >> (s)) & 0xff) << 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)((((twocolor[0]) >> (16)) & 0xff) | ((((twocolor[0] ) >> (16)) & 0xff) << 8)), | |||
1628 | GetColor(twocolor[0], 8)((((twocolor[0]) >> (8)) & 0xff) | ((((twocolor[0]) >> (8)) & 0xff) << 8)), | |||
1629 | GetColor(twocolor[0], 0)((((twocolor[0]) >> (0)) & 0xff) | ((((twocolor[0]) >> (0)) & 0xff) << 8)), | |||
1630 | GetColor(twocolor[1], 16)((((twocolor[1]) >> (16)) & 0xff) | ((((twocolor[1] ) >> (16)) & 0xff) << 8)), | |||
1631 | GetColor(twocolor[1], 8)((((twocolor[1]) >> (8)) & 0xff) | ((((twocolor[1]) >> (8)) & 0xff) << 8)), | |||
1632 | GetColor(twocolor[1], 0)((((twocolor[1]) >> (0)) & 0xff) | ((((twocolor[1]) >> (0)) & 0xff) << 8)), | |||
1633 | &pCursor, client, stuff->cid); | |||
1634 | if (rc != Success0) | |||
1635 | goto bail; | |||
1636 | if (!AddResourceDarwin_X_AddResource(stuff->cid, RT_CURSOR((RESTYPE)5), (void *) pCursor)) { | |||
1637 | rc = BadAlloc11; | |||
1638 | goto bail; | |||
1639 | } | |||
1640 | ||||
1641 | return Success0; | |||
1642 | bail: | |||
1643 | free(srcbits); | |||
1644 | free(mskbits); | |||
1645 | return rc; | |||
1646 | } | |||
1647 | ||||
1648 | static int | |||
1649 | ProcRenderSetPictureTransform(ClientPtr client) | |||
1650 | { | |||
1651 | REQUEST(xRenderSetPictureTransformReq)xRenderSetPictureTransformReq *stuff = (xRenderSetPictureTransformReq *)client->requestBuffer; | |||
1652 | PicturePtr pPicture; | |||
1653 | ||||
1654 | REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq)if ((sizeof(xRenderSetPictureTransformReq) >> 2) != client ->req_len) return(16); | |||
1655 | VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess){ int tmprc = dixLookupResourceByType((void *)&(pPicture) , stuff->picture, PictureType, client, (1<<5)); if ( tmprc != 0) return tmprc;}; | |||
1656 | return SetPictureTransform(pPicture, (PictTransform *) &stuff->transform); | |||
1657 | } | |||
1658 | ||||
1659 | static int | |||
1660 | ProcRenderQueryFilters(ClientPtr client) | |||
1661 | { | |||
1662 | REQUEST(xRenderQueryFiltersReq)xRenderQueryFiltersReq *stuff = (xRenderQueryFiltersReq *)client ->requestBuffer; | |||
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)if ((sizeof(xRenderQueryFiltersReq) >> 2) != client-> req_len) return(16); | |||
1674 | rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, | |||
1675 | DixGetAttrAccess(1<<4)); | |||
1676 | if (rc != Success0) | |||
1677 | return rc; | |||
1678 | ||||
1679 | pScreen = pDrawable->pScreen; | |||
1680 | nbytesName = 0; | |||
1681 | nnames = 0; | |||
1682 | ps = GetPictureScreenIfSet(pScreen)(dixPrivateKeyRegistered((&PictureScreenPrivateKeyRec)) ? ((PictureScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates , (&PictureScreenPrivateKeyRec))) : ((void*)0)); | |||
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 BadAlloc11; | |||
1695 | aliases = (INT16 *) (reply + 1); | |||
1696 | names = (char *) (aliases + ((nnames + 1) & ~1)); | |||
1697 | ||||
1698 | reply->type = X_Reply1; | |||
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-1; | |||
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-1; | |||
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)__builtin___memcpy_chk (names, ps->filters[i].name, j, __builtin_object_size (names, 0)); | |||
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)__builtin___memcpy_chk (names, ps->filterAliases[i].alias, j, __builtin_object_size (names, 0)); | |||
1739 | names += j; | |||
1740 | } | |||
1741 | } | |||
1742 | ||||
1743 | if (client->swapped) { | |||
1744 | for (i = 0; i < reply->numAliases; i++) { | |||
1745 | swaps(&aliases[i])do { if (sizeof(*(&aliases[i])) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&aliases[i]) & 1) && ((uintptr_t )(&aliases[i]) & 1) == 0) *(&aliases[i]) = lswaps (*(&aliases[i])); else swap_uint16((uint16_t *)(&aliases [i])); } while (0); | |||
1746 | } | |||
1747 | swaps(&reply->sequenceNumber)do { if (sizeof(*(&reply->sequenceNumber)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&reply->sequenceNumber ) & 1) && ((uintptr_t)(&reply->sequenceNumber ) & 1) == 0) *(&reply->sequenceNumber) = lswaps(*( &reply->sequenceNumber)); else swap_uint16((uint16_t * )(&reply->sequenceNumber)); } while (0); | |||
1748 | swapl(&reply->length)do { if (sizeof(*(&reply->length)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&reply->length) & 3) && ((uintptr_t)(&reply->length) & 3) == 0) *(&reply->length) = lswapl(*(&reply->length )); else swap_uint32((uint32_t *)(&reply->length)); } while (0); | |||
1749 | swapl(&reply->numAliases)do { if (sizeof(*(&reply->numAliases)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&reply->numAliases ) & 3) && ((uintptr_t)(&reply->numAliases) & 3) == 0) *(&reply->numAliases) = lswapl(*(& reply->numAliases)); else swap_uint32((uint32_t *)(&reply ->numAliases)); } while (0); | |||
1750 | swapl(&reply->numFilters)do { if (sizeof(*(&reply->numFilters)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&reply->numFilters ) & 3) && ((uintptr_t)(&reply->numFilters) & 3) == 0) *(&reply->numFilters) = lswapl(*(& reply->numFilters)); else swap_uint32((uint32_t *)(&reply ->numFilters)); } while (0); | |||
1751 | } | |||
1752 | WriteToClient(client, total_bytes, reply); | |||
1753 | free(reply); | |||
1754 | ||||
1755 | return Success0; | |||
1756 | } | |||
1757 | ||||
1758 | static int | |||
1759 | ProcRenderSetPictureFilter(ClientPtr client) | |||
1760 | { | |||
1761 | REQUEST(xRenderSetPictureFilterReq)xRenderSetPictureFilterReq *stuff = (xRenderSetPictureFilterReq *)client->requestBuffer; | |||
1762 | PicturePtr pPicture; | |||
1763 | int result; | |||
1764 | xFixed *params; | |||
1765 | int nparams; | |||
1766 | char *name; | |||
1767 | ||||
1768 | REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq)if ((sizeof(xRenderSetPictureFilterReq) >> 2) > client ->req_len ) return(16); | |||
1769 | VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess){ int tmprc = dixLookupResourceByType((void *)&(pPicture) , stuff->picture, PictureType, client, (1<<5)); if ( tmprc != 0) return tmprc;}; | |||
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)xRenderCreateAnimCursorReq *stuff = (xRenderCreateAnimCursorReq *)client->requestBuffer; | |||
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)if ((sizeof(xRenderCreateAnimCursorReq) >> 2) > client ->req_len ) return(16); | |||
1790 | LEGAL_NEW_RESOURCE(stuff->cid, client)if (!LegalNewID(stuff->cid,client)) { client->errorValue = stuff->cid; return 14; }; | |||
1791 | if (client->req_len & 1) | |||
1792 | return BadLength16; | |||
1793 | ncursor = | |||
1794 | (client->req_len - | |||
1795 | (bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1; | |||
1796 | cursors = malloc(ncursor * (sizeof(CursorPtr) + sizeof(CARD32))); | |||
1797 | if (!cursors) | |||
1798 | return BadAlloc11; | |||
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((RESTYPE)5), client, DixReadAccess(1<<0)); | |||
1804 | if (ret != Success0) { | |||
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 != Success0) | |||
1815 | return ret; | |||
1816 | ||||
1817 | if (AddResourceDarwin_X_AddResource(stuff->cid, RT_CURSOR((RESTYPE)5), (void *) pCursor)) | |||
1818 | return Success0; | |||
1819 | return BadAlloc11; | |||
1820 | } | |||
1821 | ||||
1822 | static int | |||
1823 | ProcRenderAddTraps(ClientPtr client) | |||
1824 | { | |||
1825 | int ntraps; | |||
1826 | PicturePtr pPicture; | |||
1827 | ||||
1828 | REQUEST(xRenderAddTrapsReq)xRenderAddTrapsReq *stuff = (xRenderAddTrapsReq *)client-> requestBuffer; | |||
1829 | ||||
1830 | REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq)if ((sizeof(xRenderAddTrapsReq) >> 2) > client->req_len ) return(16); | |||
1831 | VERIFY_PICTURE(pPicture, stuff->picture, client, DixWriteAccess){ int tmprc = dixLookupResourceByType((void *)&(pPicture) , stuff->picture, PictureType, client, (1<<1)); if ( tmprc != 0) return tmprc;}; | |||
1832 | if (!pPicture->pDrawable) | |||
1833 | return BadDrawable9; | |||
1834 | ntraps = (client->req_len << 2) - sizeof(xRenderAddTrapsReq); | |||
1835 | if (ntraps % sizeof(xTrap)) | |||
1836 | return BadLength16; | |||
1837 | ntraps /= sizeof(xTrap); | |||
1838 | if (ntraps) | |||
1839 | AddTraps(pPicture, | |||
1840 | stuff->xOff, stuff->yOff, ntraps, (xTrap *) &stuff[1]); | |||
1841 | return Success0; | |||
1842 | } | |||
1843 | ||||
1844 | static int | |||
1845 | ProcRenderCreateSolidFill(ClientPtr client) | |||
1846 | { | |||
1847 | PicturePtr pPicture; | |||
1848 | int error = 0; | |||
1849 | ||||
1850 | REQUEST(xRenderCreateSolidFillReq)xRenderCreateSolidFillReq *stuff = (xRenderCreateSolidFillReq *)client->requestBuffer; | |||
1851 | ||||
1852 | REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq)if ((sizeof(xRenderCreateSolidFillReq) >> 2) > client ->req_len ) return(16); | |||
1853 | ||||
1854 | LEGAL_NEW_RESOURCE(stuff->pid, client)if (!LegalNewID(stuff->pid,client)) { client->errorValue = stuff->pid; return 14; }; | |||
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_ACCESS2, client, stuff->pid, PictureType, | |||
1861 | pPicture, RT_NONE((RESTYPE)0), NULL((void*)0), DixCreateAccess(1<<3)); | |||
1862 | if (error != Success0) | |||
1863 | return error; | |||
1864 | if (!AddResourceDarwin_X_AddResource(stuff->pid, PictureType, (void *) pPicture)) | |||
1865 | return BadAlloc11; | |||
1866 | return Success0; | |||
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)xRenderCreateLinearGradientReq *stuff = (xRenderCreateLinearGradientReq *)client->requestBuffer; | |||
1879 | ||||
1880 | REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq)if ((sizeof(xRenderCreateLinearGradientReq) >> 2) > client ->req_len ) return(16); | |||
1881 | ||||
1882 | LEGAL_NEW_RESOURCE(stuff->pid, client)if (!LegalNewID(stuff->pid,client)) { client->errorValue = stuff->pid; return 14; }; | |||
1883 | ||||
1884 | len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq); | |||
1885 | if (stuff->nStops > UINT32_MAX4294967295U / (sizeof(xFixed) + sizeof(xRenderColor))) | |||
1886 | return BadLength16; | |||
1887 | if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor))) | |||
1888 | return BadLength16; | |||
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_ACCESS2, client, stuff->pid, PictureType, | |||
1900 | pPicture, RT_NONE((RESTYPE)0), NULL((void*)0), DixCreateAccess(1<<3)); | |||
1901 | if (error != Success0) | |||
1902 | return error; | |||
1903 | if (!AddResourceDarwin_X_AddResource(stuff->pid, PictureType, (void *) pPicture)) | |||
1904 | return BadAlloc11; | |||
1905 | return Success0; | |||
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)xRenderCreateRadialGradientReq *stuff = (xRenderCreateRadialGradientReq *)client->requestBuffer; | |||
1918 | ||||
1919 | REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq)if ((sizeof(xRenderCreateRadialGradientReq) >> 2) > client ->req_len ) return(16); | |||
1920 | ||||
1921 | LEGAL_NEW_RESOURCE(stuff->pid, client)if (!LegalNewID(stuff->pid,client)) { client->errorValue = stuff->pid; return 14; }; | |||
1922 | ||||
1923 | len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq); | |||
1924 | if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor))) | |||
1925 | return BadLength16; | |||
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_ACCESS2, client, stuff->pid, PictureType, | |||
1938 | pPicture, RT_NONE((RESTYPE)0), NULL((void*)0), DixCreateAccess(1<<3)); | |||
1939 | if (error != Success0) | |||
1940 | return error; | |||
1941 | if (!AddResourceDarwin_X_AddResource(stuff->pid, PictureType, (void *) pPicture)) | |||
1942 | return BadAlloc11; | |||
1943 | return Success0; | |||
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)xRenderCreateConicalGradientReq *stuff = (xRenderCreateConicalGradientReq *)client->requestBuffer; | |||
1956 | ||||
1957 | REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq)if ((sizeof(xRenderCreateConicalGradientReq) >> 2) > client->req_len ) return(16); | |||
1958 | ||||
1959 | LEGAL_NEW_RESOURCE(stuff->pid, client)if (!LegalNewID(stuff->pid,client)) { client->errorValue = stuff->pid; return 14; }; | |||
1960 | ||||
1961 | len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq); | |||
1962 | if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor))) | |||
1963 | return BadLength16; | |||
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_ACCESS2, client, stuff->pid, PictureType, | |||
1975 | pPicture, RT_NONE((RESTYPE)0), NULL((void*)0), DixCreateAccess(1<<3)); | |||
1976 | if (error != Success0) | |||
1977 | return error; | |||
1978 | if (!AddResourceDarwin_X_AddResource(stuff->pid, PictureType, (void *) pPicture)) | |||
1979 | return BadAlloc11; | |||
1980 | return Success0; | |||
1981 | } | |||
1982 | ||||
1983 | static int | |||
1984 | ProcRenderDispatch(ClientPtr client) | |||
1985 | { | |||
1986 | REQUEST(xReq)xReq *stuff = (xReq *)client->requestBuffer; | |||
1987 | ||||
1988 | if (stuff->data < RenderNumberRequests(36 +1)) | |||
1989 | return (*ProcRenderVector[stuff->data]) (client); | |||
1990 | else | |||
1991 | return BadRequest1; | |||
1992 | } | |||
1993 | ||||
1994 | static int | |||
1995 | SProcRenderQueryVersion(ClientPtr client) | |||
1996 | { | |||
1997 | REQUEST(xRenderQueryVersionReq)xRenderQueryVersionReq *stuff = (xRenderQueryVersionReq *)client ->requestBuffer; | |||
1998 | REQUEST_SIZE_MATCH(xRenderQueryVersionReq)if ((sizeof(xRenderQueryVersionReq) >> 2) != client-> req_len) return(16); | |||
1999 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2000 | swapl(&stuff->majorVersion)do { if (sizeof(*(&stuff->majorVersion)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->majorVersion ) & 3) && ((uintptr_t)(&stuff->majorVersion ) & 3) == 0) *(&stuff->majorVersion) = lswapl(*(& stuff->majorVersion)); else swap_uint32((uint32_t *)(& stuff->majorVersion)); } while (0); | |||
2001 | swapl(&stuff->minorVersion)do { if (sizeof(*(&stuff->minorVersion)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->minorVersion ) & 3) && ((uintptr_t)(&stuff->minorVersion ) & 3) == 0) *(&stuff->minorVersion) = lswapl(*(& stuff->minorVersion)); else swap_uint32((uint32_t *)(& stuff->minorVersion)); } while (0); | |||
2002 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2003 | } | |||
2004 | ||||
2005 | static int | |||
2006 | SProcRenderQueryPictFormats(ClientPtr client) | |||
2007 | { | |||
2008 | REQUEST(xRenderQueryPictFormatsReq)xRenderQueryPictFormatsReq *stuff = (xRenderQueryPictFormatsReq *)client->requestBuffer; | |||
2009 | REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq)if ((sizeof(xRenderQueryPictFormatsReq) >> 2) != client ->req_len) return(16); | |||
2010 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2011 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2012 | } | |||
2013 | ||||
2014 | static int | |||
2015 | SProcRenderQueryPictIndexValues(ClientPtr client) | |||
2016 | { | |||
2017 | REQUEST(xRenderQueryPictIndexValuesReq)xRenderQueryPictIndexValuesReq *stuff = (xRenderQueryPictIndexValuesReq *)client->requestBuffer; | |||
2018 | REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq)if ((sizeof(xRenderQueryPictIndexValuesReq) >> 2) > client ->req_len ) return(16); | |||
2019 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2020 | swapl(&stuff->format)do { if (sizeof(*(&stuff->format)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->format) & 3) && ((uintptr_t)(&stuff->format) & 3) == 0) *(&stuff->format) = lswapl(*(&stuff->format )); else swap_uint32((uint32_t *)(&stuff->format)); } while (0); | |||
2021 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2022 | } | |||
2023 | ||||
2024 | static int | |||
2025 | SProcRenderQueryDithers(ClientPtr client) | |||
2026 | { | |||
2027 | return BadImplementation17; | |||
2028 | } | |||
2029 | ||||
2030 | static int | |||
2031 | SProcRenderCreatePicture(ClientPtr client) | |||
2032 | { | |||
2033 | REQUEST(xRenderCreatePictureReq)xRenderCreatePictureReq *stuff = (xRenderCreatePictureReq *)client ->requestBuffer; | |||
2034 | REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq)if ((sizeof(xRenderCreatePictureReq) >> 2) > client-> req_len ) return(16); | |||
2035 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2036 | swapl(&stuff->pid)do { if (sizeof(*(&stuff->pid)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->pid) & 3 ) && ((uintptr_t)(&stuff->pid) & 3) == 0) * (&stuff->pid) = lswapl(*(&stuff->pid)); else swap_uint32 ((uint32_t *)(&stuff->pid)); } while (0); | |||
2037 | swapl(&stuff->drawable)do { if (sizeof(*(&stuff->drawable)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->drawable ) & 3) && ((uintptr_t)(&stuff->drawable) & 3) == 0) *(&stuff->drawable) = lswapl(*(&stuff-> drawable)); else swap_uint32((uint32_t *)(&stuff->drawable )); } while (0); | |||
2038 | swapl(&stuff->format)do { if (sizeof(*(&stuff->format)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->format) & 3) && ((uintptr_t)(&stuff->format) & 3) == 0) *(&stuff->format) = lswapl(*(&stuff->format )); else swap_uint32((uint32_t *)(&stuff->format)); } while (0); | |||
2039 | swapl(&stuff->mask)do { if (sizeof(*(&stuff->mask)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->mask) & 3) && ((uintptr_t)(&stuff->mask) & 3) == 0 ) *(&stuff->mask) = lswapl(*(&stuff->mask)); else swap_uint32((uint32_t *)(&stuff->mask)); } while (0); | |||
2040 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
2041 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2042 | } | |||
2043 | ||||
2044 | static int | |||
2045 | SProcRenderChangePicture(ClientPtr client) | |||
2046 | { | |||
2047 | REQUEST(xRenderChangePictureReq)xRenderChangePictureReq *stuff = (xRenderChangePictureReq *)client ->requestBuffer; | |||
2048 | REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq)if ((sizeof(xRenderChangePictureReq) >> 2) > client-> req_len ) return(16); | |||
2049 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2050 | swapl(&stuff->picture)do { if (sizeof(*(&stuff->picture)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->picture ) & 3) && ((uintptr_t)(&stuff->picture) & 3) == 0) *(&stuff->picture) = lswapl(*(&stuff-> picture)); else swap_uint32((uint32_t *)(&stuff->picture )); } while (0); | |||
2051 | swapl(&stuff->mask)do { if (sizeof(*(&stuff->mask)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->mask) & 3) && ((uintptr_t)(&stuff->mask) & 3) == 0 ) *(&stuff->mask) = lswapl(*(&stuff->mask)); else swap_uint32((uint32_t *)(&stuff->mask)); } while (0); | |||
2052 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
2053 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2054 | } | |||
2055 | ||||
2056 | static int | |||
2057 | SProcRenderSetPictureClipRectangles(ClientPtr client) | |||
2058 | { | |||
2059 | REQUEST(xRenderSetPictureClipRectanglesReq)xRenderSetPictureClipRectanglesReq *stuff = (xRenderSetPictureClipRectanglesReq *)client->requestBuffer; | |||
2060 | REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq)if ((sizeof(xRenderSetPictureClipRectanglesReq) >> 2) > client->req_len ) return(16); | |||
2061 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2062 | swapl(&stuff->picture)do { if (sizeof(*(&stuff->picture)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->picture ) & 3) && ((uintptr_t)(&stuff->picture) & 3) == 0) *(&stuff->picture) = lswapl(*(&stuff-> picture)); else swap_uint32((uint32_t *)(&stuff->picture )); } while (0); | |||
2063 | swaps(&stuff->xOrigin)do { if (sizeof(*(&stuff->xOrigin)) != 2) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->xOrigin ) & 1) && ((uintptr_t)(&stuff->xOrigin) & 1) == 0) *(&stuff->xOrigin) = lswaps(*(&stuff-> xOrigin)); else swap_uint16((uint16_t *)(&stuff->xOrigin )); } while (0); | |||
2064 | swaps(&stuff->yOrigin)do { if (sizeof(*(&stuff->yOrigin)) != 2) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->yOrigin ) & 1) && ((uintptr_t)(&stuff->yOrigin) & 1) == 0) *(&stuff->yOrigin) = lswaps(*(&stuff-> yOrigin)); else swap_uint16((uint16_t *)(&stuff->yOrigin )); } while (0); | |||
2065 | SwapRestS(stuff)SwapShorts((short *)(stuff + 1), ((client->req_len << 1) - (sizeof(*stuff) >> 1))); | |||
2066 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2067 | } | |||
2068 | ||||
2069 | static int | |||
2070 | SProcRenderFreePicture(ClientPtr client) | |||
2071 | { | |||
2072 | REQUEST(xRenderFreePictureReq)xRenderFreePictureReq *stuff = (xRenderFreePictureReq *)client ->requestBuffer; | |||
2073 | REQUEST_SIZE_MATCH(xRenderFreePictureReq)if ((sizeof(xRenderFreePictureReq) >> 2) != client-> req_len) return(16); | |||
2074 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2075 | swapl(&stuff->picture)do { if (sizeof(*(&stuff->picture)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->picture ) & 3) && ((uintptr_t)(&stuff->picture) & 3) == 0) *(&stuff->picture) = lswapl(*(&stuff-> picture)); else swap_uint32((uint32_t *)(&stuff->picture )); } while (0); | |||
2076 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2077 | } | |||
2078 | ||||
2079 | static int | |||
2080 | SProcRenderComposite(ClientPtr client) | |||
2081 | { | |||
2082 | REQUEST(xRenderCompositeReq)xRenderCompositeReq *stuff = (xRenderCompositeReq *)client-> requestBuffer; | |||
2083 | REQUEST_SIZE_MATCH(xRenderCompositeReq)if ((sizeof(xRenderCompositeReq) >> 2) != client->req_len ) return(16); | |||
2084 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2085 | swapl(&stuff->src)do { if (sizeof(*(&stuff->src)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->src) & 3 ) && ((uintptr_t)(&stuff->src) & 3) == 0) * (&stuff->src) = lswapl(*(&stuff->src)); else swap_uint32 ((uint32_t *)(&stuff->src)); } while (0); | |||
2086 | swapl(&stuff->mask)do { if (sizeof(*(&stuff->mask)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->mask) & 3) && ((uintptr_t)(&stuff->mask) & 3) == 0 ) *(&stuff->mask) = lswapl(*(&stuff->mask)); else swap_uint32((uint32_t *)(&stuff->mask)); } while (0); | |||
2087 | swapl(&stuff->dst)do { if (sizeof(*(&stuff->dst)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->dst) & 3 ) && ((uintptr_t)(&stuff->dst) & 3) == 0) * (&stuff->dst) = lswapl(*(&stuff->dst)); else swap_uint32 ((uint32_t *)(&stuff->dst)); } while (0); | |||
2088 | swaps(&stuff->xSrc)do { if (sizeof(*(&stuff->xSrc)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->xSrc) & 1) && ((uintptr_t)(&stuff->xSrc) & 1) == 0 ) *(&stuff->xSrc) = lswaps(*(&stuff->xSrc)); else swap_uint16((uint16_t *)(&stuff->xSrc)); } while (0); | |||
2089 | swaps(&stuff->ySrc)do { if (sizeof(*(&stuff->ySrc)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->ySrc) & 1) && ((uintptr_t)(&stuff->ySrc) & 1) == 0 ) *(&stuff->ySrc) = lswaps(*(&stuff->ySrc)); else swap_uint16((uint16_t *)(&stuff->ySrc)); } while (0); | |||
2090 | swaps(&stuff->xMask)do { if (sizeof(*(&stuff->xMask)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->xMask) & 1) && ((uintptr_t)(&stuff->xMask) & 1) == 0) *(&stuff->xMask) = lswaps(*(&stuff->xMask)) ; else swap_uint16((uint16_t *)(&stuff->xMask)); } while (0); | |||
2091 | swaps(&stuff->yMask)do { if (sizeof(*(&stuff->yMask)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->yMask) & 1) && ((uintptr_t)(&stuff->yMask) & 1) == 0) *(&stuff->yMask) = lswaps(*(&stuff->yMask)) ; else swap_uint16((uint16_t *)(&stuff->yMask)); } while (0); | |||
2092 | swaps(&stuff->xDst)do { if (sizeof(*(&stuff->xDst)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->xDst) & 1) && ((uintptr_t)(&stuff->xDst) & 1) == 0 ) *(&stuff->xDst) = lswaps(*(&stuff->xDst)); else swap_uint16((uint16_t *)(&stuff->xDst)); } while (0); | |||
2093 | swaps(&stuff->yDst)do { if (sizeof(*(&stuff->yDst)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->yDst) & 1) && ((uintptr_t)(&stuff->yDst) & 1) == 0 ) *(&stuff->yDst) = lswaps(*(&stuff->yDst)); else swap_uint16((uint16_t *)(&stuff->yDst)); } while (0); | |||
2094 | swaps(&stuff->width)do { if (sizeof(*(&stuff->width)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->width) & 1) && ((uintptr_t)(&stuff->width) & 1) == 0) *(&stuff->width) = lswaps(*(&stuff->width)) ; else swap_uint16((uint16_t *)(&stuff->width)); } while (0); | |||
2095 | swaps(&stuff->height)do { if (sizeof(*(&stuff->height)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->height) & 1) && ((uintptr_t)(&stuff->height) & 1) == 0) *(&stuff->height) = lswaps(*(&stuff->height )); else swap_uint16((uint16_t *)(&stuff->height)); } while (0); | |||
2096 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2097 | } | |||
2098 | ||||
2099 | static int | |||
2100 | SProcRenderScale(ClientPtr client) | |||
2101 | { | |||
2102 | return BadImplementation17; | |||
2103 | } | |||
2104 | ||||
2105 | static int | |||
2106 | SProcRenderTrapezoids(ClientPtr client) | |||
2107 | { | |||
2108 | REQUEST(xRenderTrapezoidsReq)xRenderTrapezoidsReq *stuff = (xRenderTrapezoidsReq *)client-> requestBuffer; | |||
2109 | ||||
2110 | REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq)if ((sizeof(xRenderTrapezoidsReq) >> 2) > client-> req_len ) return(16); | |||
2111 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2112 | swapl(&stuff->src)do { if (sizeof(*(&stuff->src)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->src) & 3 ) && ((uintptr_t)(&stuff->src) & 3) == 0) * (&stuff->src) = lswapl(*(&stuff->src)); else swap_uint32 ((uint32_t *)(&stuff->src)); } while (0); | |||
2113 | swapl(&stuff->dst)do { if (sizeof(*(&stuff->dst)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->dst) & 3 ) && ((uintptr_t)(&stuff->dst) & 3) == 0) * (&stuff->dst) = lswapl(*(&stuff->dst)); else swap_uint32 ((uint32_t *)(&stuff->dst)); } while (0); | |||
2114 | swapl(&stuff->maskFormat)do { if (sizeof(*(&stuff->maskFormat)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->maskFormat ) & 3) && ((uintptr_t)(&stuff->maskFormat) & 3) == 0) *(&stuff->maskFormat) = lswapl(*(& stuff->maskFormat)); else swap_uint32((uint32_t *)(&stuff ->maskFormat)); } while (0); | |||
2115 | swaps(&stuff->xSrc)do { if (sizeof(*(&stuff->xSrc)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->xSrc) & 1) && ((uintptr_t)(&stuff->xSrc) & 1) == 0 ) *(&stuff->xSrc) = lswaps(*(&stuff->xSrc)); else swap_uint16((uint16_t *)(&stuff->xSrc)); } while (0); | |||
2116 | swaps(&stuff->ySrc)do { if (sizeof(*(&stuff->ySrc)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->ySrc) & 1) && ((uintptr_t)(&stuff->ySrc) & 1) == 0 ) *(&stuff->ySrc) = lswaps(*(&stuff->ySrc)); else swap_uint16((uint16_t *)(&stuff->ySrc)); } while (0); | |||
2117 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
2118 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2119 | } | |||
2120 | ||||
2121 | static int | |||
2122 | SProcRenderTriangles(ClientPtr client) | |||
2123 | { | |||
2124 | REQUEST(xRenderTrianglesReq)xRenderTrianglesReq *stuff = (xRenderTrianglesReq *)client-> requestBuffer; | |||
2125 | ||||
2126 | REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq)if ((sizeof(xRenderTrianglesReq) >> 2) > client-> req_len ) return(16); | |||
2127 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2128 | swapl(&stuff->src)do { if (sizeof(*(&stuff->src)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->src) & 3 ) && ((uintptr_t)(&stuff->src) & 3) == 0) * (&stuff->src) = lswapl(*(&stuff->src)); else swap_uint32 ((uint32_t *)(&stuff->src)); } while (0); | |||
2129 | swapl(&stuff->dst)do { if (sizeof(*(&stuff->dst)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->dst) & 3 ) && ((uintptr_t)(&stuff->dst) & 3) == 0) * (&stuff->dst) = lswapl(*(&stuff->dst)); else swap_uint32 ((uint32_t *)(&stuff->dst)); } while (0); | |||
2130 | swapl(&stuff->maskFormat)do { if (sizeof(*(&stuff->maskFormat)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->maskFormat ) & 3) && ((uintptr_t)(&stuff->maskFormat) & 3) == 0) *(&stuff->maskFormat) = lswapl(*(& stuff->maskFormat)); else swap_uint32((uint32_t *)(&stuff ->maskFormat)); } while (0); | |||
2131 | swaps(&stuff->xSrc)do { if (sizeof(*(&stuff->xSrc)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->xSrc) & 1) && ((uintptr_t)(&stuff->xSrc) & 1) == 0 ) *(&stuff->xSrc) = lswaps(*(&stuff->xSrc)); else swap_uint16((uint16_t *)(&stuff->xSrc)); } while (0); | |||
2132 | swaps(&stuff->ySrc)do { if (sizeof(*(&stuff->ySrc)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->ySrc) & 1) && ((uintptr_t)(&stuff->ySrc) & 1) == 0 ) *(&stuff->ySrc) = lswaps(*(&stuff->ySrc)); else swap_uint16((uint16_t *)(&stuff->ySrc)); } while (0); | |||
2133 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
2134 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2135 | } | |||
2136 | ||||
2137 | static int | |||
2138 | SProcRenderTriStrip(ClientPtr client) | |||
2139 | { | |||
2140 | REQUEST(xRenderTriStripReq)xRenderTriStripReq *stuff = (xRenderTriStripReq *)client-> requestBuffer; | |||
2141 | ||||
2142 | REQUEST_AT_LEAST_SIZE(xRenderTriStripReq)if ((sizeof(xRenderTriStripReq) >> 2) > client->req_len ) return(16); | |||
2143 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2144 | swapl(&stuff->src)do { if (sizeof(*(&stuff->src)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->src) & 3 ) && ((uintptr_t)(&stuff->src) & 3) == 0) * (&stuff->src) = lswapl(*(&stuff->src)); else swap_uint32 ((uint32_t *)(&stuff->src)); } while (0); | |||
2145 | swapl(&stuff->dst)do { if (sizeof(*(&stuff->dst)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->dst) & 3 ) && ((uintptr_t)(&stuff->dst) & 3) == 0) * (&stuff->dst) = lswapl(*(&stuff->dst)); else swap_uint32 ((uint32_t *)(&stuff->dst)); } while (0); | |||
2146 | swapl(&stuff->maskFormat)do { if (sizeof(*(&stuff->maskFormat)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->maskFormat ) & 3) && ((uintptr_t)(&stuff->maskFormat) & 3) == 0) *(&stuff->maskFormat) = lswapl(*(& stuff->maskFormat)); else swap_uint32((uint32_t *)(&stuff ->maskFormat)); } while (0); | |||
2147 | swaps(&stuff->xSrc)do { if (sizeof(*(&stuff->xSrc)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->xSrc) & 1) && ((uintptr_t)(&stuff->xSrc) & 1) == 0 ) *(&stuff->xSrc) = lswaps(*(&stuff->xSrc)); else swap_uint16((uint16_t *)(&stuff->xSrc)); } while (0); | |||
2148 | swaps(&stuff->ySrc)do { if (sizeof(*(&stuff->ySrc)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->ySrc) & 1) && ((uintptr_t)(&stuff->ySrc) & 1) == 0 ) *(&stuff->ySrc) = lswaps(*(&stuff->ySrc)); else swap_uint16((uint16_t *)(&stuff->ySrc)); } while (0); | |||
2149 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
2150 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2151 | } | |||
2152 | ||||
2153 | static int | |||
2154 | SProcRenderTriFan(ClientPtr client) | |||
2155 | { | |||
2156 | REQUEST(xRenderTriFanReq)xRenderTriFanReq *stuff = (xRenderTriFanReq *)client->requestBuffer; | |||
2157 | ||||
2158 | REQUEST_AT_LEAST_SIZE(xRenderTriFanReq)if ((sizeof(xRenderTriFanReq) >> 2) > client->req_len ) return(16); | |||
2159 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2160 | swapl(&stuff->src)do { if (sizeof(*(&stuff->src)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->src) & 3 ) && ((uintptr_t)(&stuff->src) & 3) == 0) * (&stuff->src) = lswapl(*(&stuff->src)); else swap_uint32 ((uint32_t *)(&stuff->src)); } while (0); | |||
2161 | swapl(&stuff->dst)do { if (sizeof(*(&stuff->dst)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->dst) & 3 ) && ((uintptr_t)(&stuff->dst) & 3) == 0) * (&stuff->dst) = lswapl(*(&stuff->dst)); else swap_uint32 ((uint32_t *)(&stuff->dst)); } while (0); | |||
2162 | swapl(&stuff->maskFormat)do { if (sizeof(*(&stuff->maskFormat)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->maskFormat ) & 3) && ((uintptr_t)(&stuff->maskFormat) & 3) == 0) *(&stuff->maskFormat) = lswapl(*(& stuff->maskFormat)); else swap_uint32((uint32_t *)(&stuff ->maskFormat)); } while (0); | |||
2163 | swaps(&stuff->xSrc)do { if (sizeof(*(&stuff->xSrc)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->xSrc) & 1) && ((uintptr_t)(&stuff->xSrc) & 1) == 0 ) *(&stuff->xSrc) = lswaps(*(&stuff->xSrc)); else swap_uint16((uint16_t *)(&stuff->xSrc)); } while (0); | |||
2164 | swaps(&stuff->ySrc)do { if (sizeof(*(&stuff->ySrc)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->ySrc) & 1) && ((uintptr_t)(&stuff->ySrc) & 1) == 0 ) *(&stuff->ySrc) = lswaps(*(&stuff->ySrc)); else swap_uint16((uint16_t *)(&stuff->ySrc)); } while (0); | |||
2165 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
2166 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2167 | } | |||
2168 | ||||
2169 | static int | |||
2170 | SProcRenderColorTrapezoids(ClientPtr client) | |||
2171 | { | |||
2172 | return BadImplementation17; | |||
2173 | } | |||
2174 | ||||
2175 | static int | |||
2176 | SProcRenderColorTriangles(ClientPtr client) | |||
2177 | { | |||
2178 | return BadImplementation17; | |||
2179 | } | |||
2180 | ||||
2181 | static int | |||
2182 | SProcRenderTransform(ClientPtr client) | |||
2183 | { | |||
2184 | return BadImplementation17; | |||
2185 | } | |||
2186 | ||||
2187 | static int | |||
2188 | SProcRenderCreateGlyphSet(ClientPtr client) | |||
2189 | { | |||
2190 | REQUEST(xRenderCreateGlyphSetReq)xRenderCreateGlyphSetReq *stuff = (xRenderCreateGlyphSetReq * )client->requestBuffer; | |||
2191 | REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq)if ((sizeof(xRenderCreateGlyphSetReq) >> 2) != client-> req_len) return(16); | |||
2192 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2193 | swapl(&stuff->gsid)do { if (sizeof(*(&stuff->gsid)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->gsid) & 3) && ((uintptr_t)(&stuff->gsid) & 3) == 0 ) *(&stuff->gsid) = lswapl(*(&stuff->gsid)); else swap_uint32((uint32_t *)(&stuff->gsid)); } while (0); | |||
2194 | swapl(&stuff->format)do { if (sizeof(*(&stuff->format)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->format) & 3) && ((uintptr_t)(&stuff->format) & 3) == 0) *(&stuff->format) = lswapl(*(&stuff->format )); else swap_uint32((uint32_t *)(&stuff->format)); } while (0); | |||
2195 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2196 | } | |||
2197 | ||||
2198 | static int | |||
2199 | SProcRenderReferenceGlyphSet(ClientPtr client) | |||
2200 | { | |||
2201 | REQUEST(xRenderReferenceGlyphSetReq)xRenderReferenceGlyphSetReq *stuff = (xRenderReferenceGlyphSetReq *)client->requestBuffer; | |||
2202 | REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq)if ((sizeof(xRenderReferenceGlyphSetReq) >> 2) != client ->req_len) return(16); | |||
2203 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2204 | swapl(&stuff->gsid)do { if (sizeof(*(&stuff->gsid)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->gsid) & 3) && ((uintptr_t)(&stuff->gsid) & 3) == 0 ) *(&stuff->gsid) = lswapl(*(&stuff->gsid)); else swap_uint32((uint32_t *)(&stuff->gsid)); } while (0); | |||
2205 | swapl(&stuff->existing)do { if (sizeof(*(&stuff->existing)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->existing ) & 3) && ((uintptr_t)(&stuff->existing) & 3) == 0) *(&stuff->existing) = lswapl(*(&stuff-> existing)); else swap_uint32((uint32_t *)(&stuff->existing )); } while (0); | |||
2206 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2207 | } | |||
2208 | ||||
2209 | static int | |||
2210 | SProcRenderFreeGlyphSet(ClientPtr client) | |||
2211 | { | |||
2212 | REQUEST(xRenderFreeGlyphSetReq)xRenderFreeGlyphSetReq *stuff = (xRenderFreeGlyphSetReq *)client ->requestBuffer; | |||
2213 | REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq)if ((sizeof(xRenderFreeGlyphSetReq) >> 2) != client-> req_len) return(16); | |||
2214 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2215 | swapl(&stuff->glyphset)do { if (sizeof(*(&stuff->glyphset)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->glyphset ) & 3) && ((uintptr_t)(&stuff->glyphset) & 3) == 0) *(&stuff->glyphset) = lswapl(*(&stuff-> glyphset)); else swap_uint32((uint32_t *)(&stuff->glyphset )); } while (0); | |||
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)xRenderAddGlyphsReq *stuff = (xRenderAddGlyphsReq *)client-> requestBuffer; | |||
2228 | REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq)if ((sizeof(xRenderAddGlyphsReq) >> 2) > client-> req_len ) return(16); | |||
2229 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2230 | swapl(&stuff->glyphset)do { if (sizeof(*(&stuff->glyphset)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->glyphset ) & 3) && ((uintptr_t)(&stuff->glyphset) & 3) == 0) *(&stuff->glyphset) = lswapl(*(&stuff-> glyphset)); else swap_uint32((uint32_t *)(&stuff->glyphset )); } while (0); | |||
2231 | swapl(&stuff->nglyphs)do { if (sizeof(*(&stuff->nglyphs)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->nglyphs ) & 3) && ((uintptr_t)(&stuff->nglyphs) & 3) == 0) *(&stuff->nglyphs) = lswapl(*(&stuff-> nglyphs)); else swap_uint32((uint32_t *)(&stuff->nglyphs )); } while (0); | |||
2232 | if (stuff->nglyphs & 0xe0000000) | |||
2233 | return BadLength16; | |||
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 BadLength16; | |||
2239 | if ((char *) end - (char *) (gi + stuff->nglyphs) < 0) | |||
2240 | return BadLength16; | |||
2241 | for (i = 0; i < stuff->nglyphs; i++) { | |||
2242 | swapl(&gids[i])do { if (sizeof(*(&gids[i])) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&gids[i]) & 3) && ((uintptr_t)(& gids[i]) & 3) == 0) *(&gids[i]) = lswapl(*(&gids[ i])); else swap_uint32((uint32_t *)(&gids[i])); } while ( 0); | |||
2243 | swaps(&gi[i].width)do { if (sizeof(*(&gi[i].width)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&gi[i].width) & 1) && ((uintptr_t)(&gi[i].width) & 1) == 0) *(&gi[i].width ) = lswaps(*(&gi[i].width)); else swap_uint16((uint16_t * )(&gi[i].width)); } while (0); | |||
2244 | swaps(&gi[i].height)do { if (sizeof(*(&gi[i].height)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&gi[i].height) & 1) && ((uintptr_t)(&gi[i].height) & 1) == 0) *(&gi[i]. height) = lswaps(*(&gi[i].height)); else swap_uint16((uint16_t *)(&gi[i].height)); } while (0); | |||
2245 | swaps(&gi[i].x)do { if (sizeof(*(&gi[i].x)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&gi[i].x) & 1) && ((uintptr_t)(& gi[i].x) & 1) == 0) *(&gi[i].x) = lswaps(*(&gi[i] .x)); else swap_uint16((uint16_t *)(&gi[i].x)); } while ( 0); | |||
2246 | swaps(&gi[i].y)do { if (sizeof(*(&gi[i].y)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&gi[i].y) & 1) && ((uintptr_t)(& gi[i].y) & 1) == 0) *(&gi[i].y) = lswaps(*(&gi[i] .y)); else swap_uint16((uint16_t *)(&gi[i].y)); } while ( 0); | |||
2247 | swaps(&gi[i].xOff)do { if (sizeof(*(&gi[i].xOff)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&gi[i].xOff) & 1) && ((uintptr_t )(&gi[i].xOff) & 1) == 0) *(&gi[i].xOff) = lswaps (*(&gi[i].xOff)); else swap_uint16((uint16_t *)(&gi[i ].xOff)); } while (0); | |||
2248 | swaps(&gi[i].yOff)do { if (sizeof(*(&gi[i].yOff)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&gi[i].yOff) & 1) && ((uintptr_t )(&gi[i].yOff) & 1) == 0) *(&gi[i].yOff) = lswaps (*(&gi[i].yOff)); else swap_uint16((uint16_t *)(&gi[i ].yOff)); } while (0); | |||
2249 | } | |||
2250 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2251 | } | |||
2252 | ||||
2253 | static int | |||
2254 | SProcRenderAddGlyphsFromPicture(ClientPtr client) | |||
2255 | { | |||
2256 | return BadImplementation17; | |||
2257 | } | |||
2258 | ||||
2259 | static int | |||
2260 | SProcRenderFreeGlyphs(ClientPtr client) | |||
2261 | { | |||
2262 | REQUEST(xRenderFreeGlyphsReq)xRenderFreeGlyphsReq *stuff = (xRenderFreeGlyphsReq *)client-> requestBuffer; | |||
2263 | REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq)if ((sizeof(xRenderFreeGlyphsReq) >> 2) > client-> req_len ) return(16); | |||
2264 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2265 | swapl(&stuff->glyphset)do { if (sizeof(*(&stuff->glyphset)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->glyphset ) & 3) && ((uintptr_t)(&stuff->glyphset) & 3) == 0) *(&stuff->glyphset) = lswapl(*(&stuff-> glyphset)); else swap_uint32((uint32_t *)(&stuff->glyphset )); } while (0); | |||
2266 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
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)xRenderCompositeGlyphsReq *stuff = (xRenderCompositeGlyphsReq *)client->requestBuffer; | |||
2281 | REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq)if ((sizeof(xRenderCompositeGlyphsReq) >> 2) > client ->req_len ) return(16); | |||
2282 | ||||
2283 | switch (stuff->renderReqType) { | |||
2284 | default: | |||
2285 | size = 1; | |||
2286 | break; | |||
2287 | case X_RenderCompositeGlyphs1624: | |||
2288 | size = 2; | |||
2289 | break; | |||
2290 | case X_RenderCompositeGlyphs3225: | |||
2291 | size = 4; | |||
2292 | break; | |||
2293 | } | |||
2294 | ||||
2295 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2296 | swapl(&stuff->src)do { if (sizeof(*(&stuff->src)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->src) & 3 ) && ((uintptr_t)(&stuff->src) & 3) == 0) * (&stuff->src) = lswapl(*(&stuff->src)); else swap_uint32 ((uint32_t *)(&stuff->src)); } while (0); | |||
2297 | swapl(&stuff->dst)do { if (sizeof(*(&stuff->dst)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->dst) & 3 ) && ((uintptr_t)(&stuff->dst) & 3) == 0) * (&stuff->dst) = lswapl(*(&stuff->dst)); else swap_uint32 ((uint32_t *)(&stuff->dst)); } while (0); | |||
2298 | swapl(&stuff->maskFormat)do { if (sizeof(*(&stuff->maskFormat)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->maskFormat ) & 3) && ((uintptr_t)(&stuff->maskFormat) & 3) == 0) *(&stuff->maskFormat) = lswapl(*(& stuff->maskFormat)); else swap_uint32((uint32_t *)(&stuff ->maskFormat)); } while (0); | |||
2299 | swapl(&stuff->glyphset)do { if (sizeof(*(&stuff->glyphset)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->glyphset ) & 3) && ((uintptr_t)(&stuff->glyphset) & 3) == 0) *(&stuff->glyphset) = lswapl(*(&stuff-> glyphset)); else swap_uint32((uint32_t *)(&stuff->glyphset )); } while (0); | |||
2300 | swaps(&stuff->xSrc)do { if (sizeof(*(&stuff->xSrc)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->xSrc) & 1) && ((uintptr_t)(&stuff->xSrc) & 1) == 0 ) *(&stuff->xSrc) = lswaps(*(&stuff->xSrc)); else swap_uint16((uint16_t *)(&stuff->xSrc)); } while (0); | |||
2301 | swaps(&stuff->ySrc)do { if (sizeof(*(&stuff->ySrc)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->ySrc) & 1) && ((uintptr_t)(&stuff->ySrc) & 1) == 0 ) *(&stuff->ySrc) = lswaps(*(&stuff->ySrc)); else swap_uint16((uint16_t *)(&stuff->ySrc)); } while (0); | |||
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)do { if (sizeof(*(&elt->deltax)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&elt->deltax) & 1) && ((uintptr_t)(&elt->deltax) & 1) == 0 ) *(&elt->deltax) = lswaps(*(&elt->deltax)); else swap_uint16((uint16_t *)(&elt->deltax)); } while (0); | |||
2309 | swaps(&elt->deltay)do { if (sizeof(*(&elt->deltay)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&elt->deltay) & 1) && ((uintptr_t)(&elt->deltay) & 1) == 0 ) *(&elt->deltay) = lswaps(*(&elt->deltay)); else swap_uint16((uint16_t *)(&elt->deltay)); } while (0); | |||
2310 | ||||
2311 | i = elt->len; | |||
2312 | if (i == 0xff) { | |||
2313 | swapl((int *) buffer)do { if (sizeof(*((int *) buffer)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)((int *) buffer) & 3) && ((uintptr_t) ((int *) buffer) & 3) == 0) *((int *) buffer) = lswapl(*( (int *) buffer)); else swap_uint32((uint32_t *)((int *) buffer )); } while (0); | |||
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)do { if (sizeof(*((short *) buffer)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)((short *) buffer) & 1) && ((uintptr_t)((short *) buffer) & 1) == 0) *((short *) buffer ) = lswaps(*((short *) buffer)); else swap_uint16((uint16_t * )((short *) buffer)); } while (0); | |||
2325 | buffer += 2; | |||
2326 | } | |||
2327 | break; | |||
2328 | case 4: | |||
2329 | while (i--) { | |||
2330 | swapl((int *) buffer)do { if (sizeof(*((int *) buffer)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)((int *) buffer) & 3) && ((uintptr_t) ((int *) buffer) & 3) == 0) *((int *) buffer) = lswapl(*( (int *) buffer)); else swap_uint32((uint32_t *)((int *) buffer )); } while (0); | |||
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)xRenderFillRectanglesReq *stuff = (xRenderFillRectanglesReq * )client->requestBuffer; | |||
2346 | ||||
2347 | REQUEST_AT_LEAST_SIZE(xRenderFillRectanglesReq)if ((sizeof(xRenderFillRectanglesReq) >> 2) > client ->req_len ) return(16); | |||
2348 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2349 | swapl(&stuff->dst)do { if (sizeof(*(&stuff->dst)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->dst) & 3 ) && ((uintptr_t)(&stuff->dst) & 3) == 0) * (&stuff->dst) = lswapl(*(&stuff->dst)); else swap_uint32 ((uint32_t *)(&stuff->dst)); } while (0); | |||
2350 | swaps(&stuff->color.red)do { if (sizeof(*(&stuff->color.red)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->color .red) & 1) && ((uintptr_t)(&stuff->color.red ) & 1) == 0) *(&stuff->color.red) = lswaps(*(& stuff->color.red)); else swap_uint16((uint16_t *)(&stuff ->color.red)); } while (0); | |||
2351 | swaps(&stuff->color.green)do { if (sizeof(*(&stuff->color.green)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->color .green) & 1) && ((uintptr_t)(&stuff->color .green) & 1) == 0) *(&stuff->color.green) = lswaps (*(&stuff->color.green)); else swap_uint16((uint16_t * )(&stuff->color.green)); } while (0); | |||
2352 | swaps(&stuff->color.blue)do { if (sizeof(*(&stuff->color.blue)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->color .blue) & 1) && ((uintptr_t)(&stuff->color. blue) & 1) == 0) *(&stuff->color.blue) = lswaps(*( &stuff->color.blue)); else swap_uint16((uint16_t *)(& stuff->color.blue)); } while (0); | |||
2353 | swaps(&stuff->color.alpha)do { if (sizeof(*(&stuff->color.alpha)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->color .alpha) & 1) && ((uintptr_t)(&stuff->color .alpha) & 1) == 0) *(&stuff->color.alpha) = lswaps (*(&stuff->color.alpha)); else swap_uint16((uint16_t * )(&stuff->color.alpha)); } while (0); | |||
2354 | SwapRestS(stuff)SwapShorts((short *)(stuff + 1), ((client->req_len << 1) - (sizeof(*stuff) >> 1))); | |||
2355 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2356 | } | |||
2357 | ||||
2358 | static int | |||
2359 | SProcRenderCreateCursor(ClientPtr client) | |||
2360 | { | |||
2361 | REQUEST(xRenderCreateCursorReq)xRenderCreateCursorReq *stuff = (xRenderCreateCursorReq *)client ->requestBuffer; | |||
2362 | REQUEST_SIZE_MATCH(xRenderCreateCursorReq)if ((sizeof(xRenderCreateCursorReq) >> 2) != client-> req_len) return(16); | |||
2363 | ||||
2364 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2365 | swapl(&stuff->cid)do { if (sizeof(*(&stuff->cid)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->cid) & 3 ) && ((uintptr_t)(&stuff->cid) & 3) == 0) * (&stuff->cid) = lswapl(*(&stuff->cid)); else swap_uint32 ((uint32_t *)(&stuff->cid)); } while (0); | |||
2366 | swapl(&stuff->src)do { if (sizeof(*(&stuff->src)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->src) & 3 ) && ((uintptr_t)(&stuff->src) & 3) == 0) * (&stuff->src) = lswapl(*(&stuff->src)); else swap_uint32 ((uint32_t *)(&stuff->src)); } while (0); | |||
2367 | swaps(&stuff->x)do { if (sizeof(*(&stuff->x)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&stuff->x) & 1) && ((uintptr_t)(&stuff->x) & 1) == 0) *(&stuff-> x) = lswaps(*(&stuff->x)); else swap_uint16((uint16_t * )(&stuff->x)); } while (0); | |||
2368 | swaps(&stuff->y)do { if (sizeof(*(&stuff->y)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&stuff->y) & 1) && ((uintptr_t)(&stuff->y) & 1) == 0) *(&stuff-> y) = lswaps(*(&stuff->y)); else swap_uint16((uint16_t * )(&stuff->y)); } while (0); | |||
2369 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2370 | } | |||
2371 | ||||
2372 | static int | |||
2373 | SProcRenderSetPictureTransform(ClientPtr client) | |||
2374 | { | |||
2375 | REQUEST(xRenderSetPictureTransformReq)xRenderSetPictureTransformReq *stuff = (xRenderSetPictureTransformReq *)client->requestBuffer; | |||
2376 | REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq)if ((sizeof(xRenderSetPictureTransformReq) >> 2) != client ->req_len) return(16); | |||
2377 | ||||
2378 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2379 | swapl(&stuff->picture)do { if (sizeof(*(&stuff->picture)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->picture ) & 3) && ((uintptr_t)(&stuff->picture) & 3) == 0) *(&stuff->picture) = lswapl(*(&stuff-> picture)); else swap_uint32((uint32_t *)(&stuff->picture )); } while (0); | |||
2380 | swapl(&stuff->transform.matrix11)do { if (sizeof(*(&stuff->transform.matrix11)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->transform .matrix11) & 3) && ((uintptr_t)(&stuff->transform .matrix11) & 3) == 0) *(&stuff->transform.matrix11 ) = lswapl(*(&stuff->transform.matrix11)); else swap_uint32 ((uint32_t *)(&stuff->transform.matrix11)); } while (0 ); | |||
2381 | swapl(&stuff->transform.matrix12)do { if (sizeof(*(&stuff->transform.matrix12)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->transform .matrix12) & 3) && ((uintptr_t)(&stuff->transform .matrix12) & 3) == 0) *(&stuff->transform.matrix12 ) = lswapl(*(&stuff->transform.matrix12)); else swap_uint32 ((uint32_t *)(&stuff->transform.matrix12)); } while (0 ); | |||
2382 | swapl(&stuff->transform.matrix13)do { if (sizeof(*(&stuff->transform.matrix13)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->transform .matrix13) & 3) && ((uintptr_t)(&stuff->transform .matrix13) & 3) == 0) *(&stuff->transform.matrix13 ) = lswapl(*(&stuff->transform.matrix13)); else swap_uint32 ((uint32_t *)(&stuff->transform.matrix13)); } while (0 ); | |||
2383 | swapl(&stuff->transform.matrix21)do { if (sizeof(*(&stuff->transform.matrix21)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->transform .matrix21) & 3) && ((uintptr_t)(&stuff->transform .matrix21) & 3) == 0) *(&stuff->transform.matrix21 ) = lswapl(*(&stuff->transform.matrix21)); else swap_uint32 ((uint32_t *)(&stuff->transform.matrix21)); } while (0 ); | |||
2384 | swapl(&stuff->transform.matrix22)do { if (sizeof(*(&stuff->transform.matrix22)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->transform .matrix22) & 3) && ((uintptr_t)(&stuff->transform .matrix22) & 3) == 0) *(&stuff->transform.matrix22 ) = lswapl(*(&stuff->transform.matrix22)); else swap_uint32 ((uint32_t *)(&stuff->transform.matrix22)); } while (0 ); | |||
2385 | swapl(&stuff->transform.matrix23)do { if (sizeof(*(&stuff->transform.matrix23)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->transform .matrix23) & 3) && ((uintptr_t)(&stuff->transform .matrix23) & 3) == 0) *(&stuff->transform.matrix23 ) = lswapl(*(&stuff->transform.matrix23)); else swap_uint32 ((uint32_t *)(&stuff->transform.matrix23)); } while (0 ); | |||
2386 | swapl(&stuff->transform.matrix31)do { if (sizeof(*(&stuff->transform.matrix31)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->transform .matrix31) & 3) && ((uintptr_t)(&stuff->transform .matrix31) & 3) == 0) *(&stuff->transform.matrix31 ) = lswapl(*(&stuff->transform.matrix31)); else swap_uint32 ((uint32_t *)(&stuff->transform.matrix31)); } while (0 ); | |||
2387 | swapl(&stuff->transform.matrix32)do { if (sizeof(*(&stuff->transform.matrix32)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->transform .matrix32) & 3) && ((uintptr_t)(&stuff->transform .matrix32) & 3) == 0) *(&stuff->transform.matrix32 ) = lswapl(*(&stuff->transform.matrix32)); else swap_uint32 ((uint32_t *)(&stuff->transform.matrix32)); } while (0 ); | |||
2388 | swapl(&stuff->transform.matrix33)do { if (sizeof(*(&stuff->transform.matrix33)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->transform .matrix33) & 3) && ((uintptr_t)(&stuff->transform .matrix33) & 3) == 0) *(&stuff->transform.matrix33 ) = lswapl(*(&stuff->transform.matrix33)); else swap_uint32 ((uint32_t *)(&stuff->transform.matrix33)); } while (0 ); | |||
2389 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2390 | } | |||
2391 | ||||
2392 | static int | |||
2393 | SProcRenderQueryFilters(ClientPtr client) | |||
2394 | { | |||
2395 | REQUEST(xRenderQueryFiltersReq)xRenderQueryFiltersReq *stuff = (xRenderQueryFiltersReq *)client ->requestBuffer; | |||
2396 | REQUEST_SIZE_MATCH(xRenderQueryFiltersReq)if ((sizeof(xRenderQueryFiltersReq) >> 2) != client-> req_len) return(16); | |||
2397 | ||||
2398 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2399 | swapl(&stuff->drawable)do { if (sizeof(*(&stuff->drawable)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->drawable ) & 3) && ((uintptr_t)(&stuff->drawable) & 3) == 0) *(&stuff->drawable) = lswapl(*(&stuff-> drawable)); else swap_uint32((uint32_t *)(&stuff->drawable )); } while (0); | |||
2400 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2401 | } | |||
2402 | ||||
2403 | static int | |||
2404 | SProcRenderSetPictureFilter(ClientPtr client) | |||
2405 | { | |||
2406 | REQUEST(xRenderSetPictureFilterReq)xRenderSetPictureFilterReq *stuff = (xRenderSetPictureFilterReq *)client->requestBuffer; | |||
2407 | REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq)if ((sizeof(xRenderSetPictureFilterReq) >> 2) > client ->req_len ) return(16); | |||
2408 | ||||
2409 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2410 | swapl(&stuff->picture)do { if (sizeof(*(&stuff->picture)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->picture ) & 3) && ((uintptr_t)(&stuff->picture) & 3) == 0) *(&stuff->picture) = lswapl(*(&stuff-> picture)); else swap_uint32((uint32_t *)(&stuff->picture )); } while (0); | |||
2411 | swaps(&stuff->nbytes)do { if (sizeof(*(&stuff->nbytes)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->nbytes) & 1) && ((uintptr_t)(&stuff->nbytes) & 1) == 0) *(&stuff->nbytes) = lswaps(*(&stuff->nbytes )); else swap_uint16((uint16_t *)(&stuff->nbytes)); } while (0); | |||
2412 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2413 | } | |||
2414 | ||||
2415 | static int | |||
2416 | SProcRenderCreateAnimCursor(ClientPtr client) | |||
2417 | { | |||
2418 | REQUEST(xRenderCreateAnimCursorReq)xRenderCreateAnimCursorReq *stuff = (xRenderCreateAnimCursorReq *)client->requestBuffer; | |||
2419 | REQUEST_AT_LEAST_SIZE(xRenderCreateAnimCursorReq)if ((sizeof(xRenderCreateAnimCursorReq) >> 2) > client ->req_len ) return(16); | |||
2420 | ||||
2421 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2422 | swapl(&stuff->cid)do { if (sizeof(*(&stuff->cid)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->cid) & 3 ) && ((uintptr_t)(&stuff->cid) & 3) == 0) * (&stuff->cid) = lswapl(*(&stuff->cid)); else swap_uint32 ((uint32_t *)(&stuff->cid)); } while (0); | |||
2423 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
2424 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2425 | } | |||
2426 | ||||
2427 | static int | |||
2428 | SProcRenderAddTraps(ClientPtr client) | |||
2429 | { | |||
2430 | REQUEST(xRenderAddTrapsReq)xRenderAddTrapsReq *stuff = (xRenderAddTrapsReq *)client-> requestBuffer; | |||
2431 | REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq)if ((sizeof(xRenderAddTrapsReq) >> 2) > client->req_len ) return(16); | |||
2432 | ||||
2433 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2434 | swapl(&stuff->picture)do { if (sizeof(*(&stuff->picture)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->picture ) & 3) && ((uintptr_t)(&stuff->picture) & 3) == 0) *(&stuff->picture) = lswapl(*(&stuff-> picture)); else swap_uint32((uint32_t *)(&stuff->picture )); } while (0); | |||
2435 | swaps(&stuff->xOff)do { if (sizeof(*(&stuff->xOff)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->xOff) & 1) && ((uintptr_t)(&stuff->xOff) & 1) == 0 ) *(&stuff->xOff) = lswaps(*(&stuff->xOff)); else swap_uint16((uint16_t *)(&stuff->xOff)); } while (0); | |||
2436 | swaps(&stuff->yOff)do { if (sizeof(*(&stuff->yOff)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->yOff) & 1) && ((uintptr_t)(&stuff->yOff) & 1) == 0 ) *(&stuff->yOff) = lswaps(*(&stuff->yOff)); else swap_uint16((uint16_t *)(&stuff->yOff)); } while (0); | |||
2437 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
2438 | return (*ProcRenderVector[stuff->renderReqType]) (client); | |||
2439 | } | |||
2440 | ||||
2441 | static int | |||
2442 | SProcRenderCreateSolidFill(ClientPtr client) | |||
2443 | { | |||
2444 | REQUEST(xRenderCreateSolidFillReq)xRenderCreateSolidFillReq *stuff = (xRenderCreateSolidFillReq *)client->requestBuffer; | |||
2445 | REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq)if ((sizeof(xRenderCreateSolidFillReq) >> 2) > client ->req_len ) return(16); | |||
2446 | ||||
2447 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2448 | swapl(&stuff->pid)do { if (sizeof(*(&stuff->pid)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->pid) & 3 ) && ((uintptr_t)(&stuff->pid) & 3) == 0) * (&stuff->pid) = lswapl(*(&stuff->pid)); else swap_uint32 ((uint32_t *)(&stuff->pid)); } while (0); | |||
2449 | swaps(&stuff->color.alpha)do { if (sizeof(*(&stuff->color.alpha)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->color .alpha) & 1) && ((uintptr_t)(&stuff->color .alpha) & 1) == 0) *(&stuff->color.alpha) = lswaps (*(&stuff->color.alpha)); else swap_uint16((uint16_t * )(&stuff->color.alpha)); } while (0); | |||
2450 | swaps(&stuff->color.red)do { if (sizeof(*(&stuff->color.red)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->color .red) & 1) && ((uintptr_t)(&stuff->color.red ) & 1) == 0) *(&stuff->color.red) = lswaps(*(& stuff->color.red)); else swap_uint16((uint16_t *)(&stuff ->color.red)); } while (0); | |||
2451 | swaps(&stuff->color.green)do { if (sizeof(*(&stuff->color.green)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->color .green) & 1) && ((uintptr_t)(&stuff->color .green) & 1) == 0) *(&stuff->color.green) = lswaps (*(&stuff->color.green)); else swap_uint16((uint16_t * )(&stuff->color.green)); } while (0); | |||
2452 | swaps(&stuff->color.blue)do { if (sizeof(*(&stuff->color.blue)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->color .blue) & 1) && ((uintptr_t)(&stuff->color. blue) & 1) == 0) *(&stuff->color.blue) = lswaps(*( &stuff->color.blue)); else swap_uint16((uint16_t *)(& stuff->color.blue)); } while (0); | |||
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)do { if (sizeof(*(stops)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(stops) & 3) && ((uintptr_t)(stops) & 3) == 0) *(stops) = lswapl(*(stops)); else swap_uint32((uint32_t *)(stops)); } while (0); | |||
2466 | ++stops; | |||
2467 | } | |||
2468 | colors = (CARD16 *) (stops); | |||
2469 | for (i = 0; i < 4 * num; ++i) { | |||
2470 | swaps(colors)do { if (sizeof(*(colors)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(colors) & 1) && ((uintptr_t)(colors) & 1) == 0) *(colors) = lswaps(*(colors)); else swap_uint16 ((uint16_t *)(colors)); } while (0); | |||
2471 | ++colors; | |||
2472 | } | |||
2473 | } | |||
2474 | ||||
2475 | static int | |||
2476 | SProcRenderCreateLinearGradient(ClientPtr client) | |||
2477 | { | |||
2478 | int len; | |||
2479 | ||||
2480 | REQUEST(xRenderCreateLinearGradientReq)xRenderCreateLinearGradientReq *stuff = (xRenderCreateLinearGradientReq *)client->requestBuffer; | |||
2481 | REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq)if ((sizeof(xRenderCreateLinearGradientReq) >> 2) > client ->req_len ) return(16); | |||
2482 | ||||
2483 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2484 | swapl(&stuff->pid)do { if (sizeof(*(&stuff->pid)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->pid) & 3 ) && ((uintptr_t)(&stuff->pid) & 3) == 0) * (&stuff->pid) = lswapl(*(&stuff->pid)); else swap_uint32 ((uint32_t *)(&stuff->pid)); } while (0); | |||
2485 | swapl(&stuff->p1.x)do { if (sizeof(*(&stuff->p1.x)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->p1.x) & 3) && ((uintptr_t)(&stuff->p1.x) & 3) == 0 ) *(&stuff->p1.x) = lswapl(*(&stuff->p1.x)); else swap_uint32((uint32_t *)(&stuff->p1.x)); } while (0); | |||
2486 | swapl(&stuff->p1.y)do { if (sizeof(*(&stuff->p1.y)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->p1.y) & 3) && ((uintptr_t)(&stuff->p1.y) & 3) == 0 ) *(&stuff->p1.y) = lswapl(*(&stuff->p1.y)); else swap_uint32((uint32_t *)(&stuff->p1.y)); } while (0); | |||
2487 | swapl(&stuff->p2.x)do { if (sizeof(*(&stuff->p2.x)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->p2.x) & 3) && ((uintptr_t)(&stuff->p2.x) & 3) == 0 ) *(&stuff->p2.x) = lswapl(*(&stuff->p2.x)); else swap_uint32((uint32_t *)(&stuff->p2.x)); } while (0); | |||
2488 | swapl(&stuff->p2.y)do { if (sizeof(*(&stuff->p2.y)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->p2.y) & 3) && ((uintptr_t)(&stuff->p2.y) & 3) == 0 ) *(&stuff->p2.y) = lswapl(*(&stuff->p2.y)); else swap_uint32((uint32_t *)(&stuff->p2.y)); } while (0); | |||
2489 | swapl(&stuff->nStops)do { if (sizeof(*(&stuff->nStops)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->nStops) & 3) && ((uintptr_t)(&stuff->nStops) & 3) == 0) *(&stuff->nStops) = lswapl(*(&stuff->nStops )); else swap_uint32((uint32_t *)(&stuff->nStops)); } while (0); | |||
2490 | ||||
2491 | len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq); | |||
2492 | if (stuff->nStops > UINT32_MAX4294967295U / (sizeof(xFixed) + sizeof(xRenderColor))) | |||
2493 | return BadLength16; | |||
2494 | if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor))) | |||
2495 | return BadLength16; | |||
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)xRenderCreateRadialGradientReq *stuff = (xRenderCreateRadialGradientReq *)client->requestBuffer; | |||
2508 | REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq)if ((sizeof(xRenderCreateRadialGradientReq) >> 2) > client ->req_len ) return(16); | |||
2509 | ||||
2510 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2511 | swapl(&stuff->pid)do { if (sizeof(*(&stuff->pid)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->pid) & 3 ) && ((uintptr_t)(&stuff->pid) & 3) == 0) * (&stuff->pid) = lswapl(*(&stuff->pid)); else swap_uint32 ((uint32_t *)(&stuff->pid)); } while (0); | |||
2512 | swapl(&stuff->inner.x)do { if (sizeof(*(&stuff->inner.x)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->inner.x ) & 3) && ((uintptr_t)(&stuff->inner.x) & 3) == 0) *(&stuff->inner.x) = lswapl(*(&stuff-> inner.x)); else swap_uint32((uint32_t *)(&stuff->inner .x)); } while (0); | |||
2513 | swapl(&stuff->inner.y)do { if (sizeof(*(&stuff->inner.y)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->inner.y ) & 3) && ((uintptr_t)(&stuff->inner.y) & 3) == 0) *(&stuff->inner.y) = lswapl(*(&stuff-> inner.y)); else swap_uint32((uint32_t *)(&stuff->inner .y)); } while (0); | |||
2514 | swapl(&stuff->outer.x)do { if (sizeof(*(&stuff->outer.x)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->outer.x ) & 3) && ((uintptr_t)(&stuff->outer.x) & 3) == 0) *(&stuff->outer.x) = lswapl(*(&stuff-> outer.x)); else swap_uint32((uint32_t *)(&stuff->outer .x)); } while (0); | |||
2515 | swapl(&stuff->outer.y)do { if (sizeof(*(&stuff->outer.y)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&stuff->outer.y ) & 3) && ((uintptr_t)(&stuff->outer.y) & 3) == 0) *(&stuff->outer.y) = lswapl(*(&stuff-> outer.y)); else swap_uint32((uint32_t *)(&stuff->outer .y)); } while (0); | |||
2516 | swapl(&stuff->inner_radius)do { if (sizeof(*(&stuff->inner_radius)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->inner_radius ) & 3) && ((uintptr_t)(&stuff->inner_radius ) & 3) == 0) *(&stuff->inner_radius) = lswapl(*(& stuff->inner_radius)); else swap_uint32((uint32_t *)(& stuff->inner_radius)); } while (0); | |||
2517 | swapl(&stuff->outer_radius)do { if (sizeof(*(&stuff->outer_radius)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->outer_radius ) & 3) && ((uintptr_t)(&stuff->outer_radius ) & 3) == 0) *(&stuff->outer_radius) = lswapl(*(& stuff->outer_radius)); else swap_uint32((uint32_t *)(& stuff->outer_radius)); } while (0); | |||
2518 | swapl(&stuff->nStops)do { if (sizeof(*(&stuff->nStops)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->nStops) & 3) && ((uintptr_t)(&stuff->nStops) & 3) == 0) *(&stuff->nStops) = lswapl(*(&stuff->nStops )); else swap_uint32((uint32_t *)(&stuff->nStops)); } while (0); | |||
2519 | ||||
2520 | len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq); | |||
2521 | if (stuff->nStops > UINT32_MAX4294967295U / (sizeof(xFixed) + sizeof(xRenderColor))) | |||
2522 | return BadLength16; | |||
2523 | if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor))) | |||
2524 | return BadLength16; | |||
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)xRenderCreateConicalGradientReq *stuff = (xRenderCreateConicalGradientReq *)client->requestBuffer; | |||
2537 | REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq)if ((sizeof(xRenderCreateConicalGradientReq) >> 2) > client->req_len ) return(16); | |||
2538 | ||||
2539 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2540 | swapl(&stuff->pid)do { if (sizeof(*(&stuff->pid)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->pid) & 3 ) && ((uintptr_t)(&stuff->pid) & 3) == 0) * (&stuff->pid) = lswapl(*(&stuff->pid)); else swap_uint32 ((uint32_t *)(&stuff->pid)); } while (0); | |||
2541 | swapl(&stuff->center.x)do { if (sizeof(*(&stuff->center.x)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->center .x) & 3) && ((uintptr_t)(&stuff->center.x) & 3) == 0) *(&stuff->center.x) = lswapl(*(&stuff ->center.x)); else swap_uint32((uint32_t *)(&stuff-> center.x)); } while (0); | |||
2542 | swapl(&stuff->center.y)do { if (sizeof(*(&stuff->center.y)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->center .y) & 3) && ((uintptr_t)(&stuff->center.y) & 3) == 0) *(&stuff->center.y) = lswapl(*(&stuff ->center.y)); else swap_uint32((uint32_t *)(&stuff-> center.y)); } while (0); | |||
2543 | swapl(&stuff->angle)do { if (sizeof(*(&stuff->angle)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->angle) & 3) && ((uintptr_t)(&stuff->angle) & 3) == 0) *(&stuff->angle) = lswapl(*(&stuff->angle)) ; else swap_uint32((uint32_t *)(&stuff->angle)); } while (0); | |||
2544 | swapl(&stuff->nStops)do { if (sizeof(*(&stuff->nStops)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->nStops) & 3) && ((uintptr_t)(&stuff->nStops) & 3) == 0) *(&stuff->nStops) = lswapl(*(&stuff->nStops )); else swap_uint32((uint32_t *)(&stuff->nStops)); } while (0); | |||
2545 | ||||
2546 | len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq); | |||
2547 | if (stuff->nStops > UINT32_MAX4294967295U / (sizeof(xFixed) + sizeof(xRenderColor))) | |||
2548 | return BadLength16; | |||
2549 | if (len != stuff->nStops * (sizeof(xFixed) + sizeof(xRenderColor))) | |||
2550 | return BadLength16; | |||
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)xReq *stuff = (xReq *)client->requestBuffer; | |||
2561 | ||||
2562 | if (stuff->data < RenderNumberRequests(36 +1)) | |||
2563 | return (*SProcRenderVector[stuff->data]) (client); | |||
2564 | else | |||
2565 | return BadRequest1; | |||
2566 | } | |||
2567 | ||||
2568 | #ifdef PANORAMIX1 | |||
2569 | #define VERIFY_XIN_PICTURE(pPicture, pid, client, mode){ int rc = dixLookupResourceByType((void **)&(pPicture), pid , XRT_PICTURE, client, mode); if (rc != 0) return rc;} {\ | |||
2570 | int rc = dixLookupResourceByType((void **)&(pPicture), pid,\ | |||
2571 | XRT_PICTURE, client, mode);\ | |||
2572 | if (rc != Success0)\ | |||
2573 | return rc;\ | |||
2574 | } | |||
2575 | ||||
2576 | #define VERIFY_XIN_ALPHA(pPicture, pid, client, mode){ if (pid == 0L) pPicture = 0; else { { int rc = dixLookupResourceByType ((void **)&(pPicture), pid, XRT_PICTURE, client, mode); if (rc != 0) return rc;}; } } {\ | |||
2577 | if (pid == None0L) \ | |||
2578 | pPicture = 0; \ | |||
2579 | else { \ | |||
2580 | VERIFY_XIN_PICTURE(pPicture, pid, client, mode){ int rc = dixLookupResourceByType((void **)&(pPicture), pid , XRT_PICTURE, client, mode); if (rc != 0) return rc;}; \ | |||
2581 | } \ | |||
2582 | } \ | |||
2583 | ||||
2584 | int (*PanoramiXSaveRenderVector[RenderNumberRequests(36 +1)]) (ClientPtr); | |||
2585 | ||||
2586 | static int | |||
2587 | PanoramiXRenderCreatePicture(ClientPtr client) | |||
2588 | { | |||
2589 | REQUEST(xRenderCreatePictureReq)xRenderCreatePictureReq *stuff = (xRenderCreatePictureReq *)client ->requestBuffer; | |||
2590 | PanoramiXRes *refDraw, *newPict; | |||
2591 | int result, j; | |||
2592 | ||||
2593 | REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq)if ((sizeof(xRenderCreatePictureReq) >> 2) > client-> req_len ) return(16); | |||
2594 | result = dixLookupResourceByClass((void **) &refDraw, stuff->drawable, | |||
2595 | XRC_DRAWABLE, client, DixWriteAccess(1<<1)); | |||
2596 | if (result != Success0) | |||
2597 | return (result == BadValue2) ? BadDrawable9 : result; | |||
2598 | if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) | |||
2599 | return BadAlloc11; | |||
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 = TRUE1; | |||
2606 | } | |||
2607 | else | |||
2608 | newPict->u.pict.root = FALSE0; | |||
2609 | ||||
2610 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2611 | stuff->pid = newPict->info[j].id; | |||
2612 | stuff->drawable = refDraw->info[j].id; | |||
2613 | result = (*PanoramiXSaveRenderVector[X_RenderCreatePicture4]) (client); | |||
2614 | if (result != Success0) | |||
2615 | break; | |||
2616 | } | |||
2617 | ||||
2618 | if (result == Success0) | |||
2619 | AddResourceDarwin_X_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 = Success0, j; | |||
2631 | ||||
2632 | REQUEST(xRenderChangePictureReq)xRenderChangePictureReq *stuff = (xRenderChangePictureReq *)client ->requestBuffer; | |||
2633 | ||||
2634 | REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq)if ((sizeof(xRenderChangePictureReq) >> 2) > client-> req_len ) return(16); | |||
2635 | ||||
2636 | VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess){ int rc = dixLookupResourceByType((void **)&(pict), stuff ->picture, XRT_PICTURE, client, (1<<1)); if (rc != 0 ) return rc;}; | |||
2637 | ||||
2638 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2639 | stuff->picture = pict->info[j].id; | |||
2640 | result = (*PanoramiXSaveRenderVector[X_RenderChangePicture5]) (client); | |||
2641 | if (result != Success0) | |||
2642 | break; | |||
2643 | } | |||
2644 | ||||
2645 | return result; | |||
2646 | } | |||
2647 | ||||
2648 | static int | |||
2649 | PanoramiXRenderSetPictureClipRectangles(ClientPtr client) | |||
2650 | { | |||
2651 | REQUEST(xRenderSetPictureClipRectanglesReq)xRenderSetPictureClipRectanglesReq *stuff = (xRenderSetPictureClipRectanglesReq *)client->requestBuffer; | |||
2652 | int result = Success0, j; | |||
2653 | PanoramiXRes *pict; | |||
2654 | ||||
2655 | REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq)if ((sizeof(xRenderSetPictureClipRectanglesReq) >> 2) > client->req_len ) return(16); | |||
2656 | ||||
2657 | VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess){ int rc = dixLookupResourceByType((void **)&(pict), stuff ->picture, XRT_PICTURE, client, (1<<1)); if (rc != 0 ) return rc;}; | |||
2658 | ||||
2659 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2660 | stuff->picture = pict->info[j].id; | |||
2661 | result = | |||
2662 | (*PanoramiXSaveRenderVector[X_RenderSetPictureClipRectangles6]) | |||
2663 | (client); | |||
2664 | if (result != Success0) | |||
2665 | break; | |||
2666 | } | |||
2667 | ||||
2668 | return result; | |||
2669 | } | |||
2670 | ||||
2671 | static int | |||
2672 | PanoramiXRenderSetPictureTransform(ClientPtr client) | |||
2673 | { | |||
2674 | REQUEST(xRenderSetPictureTransformReq)xRenderSetPictureTransformReq *stuff = (xRenderSetPictureTransformReq *)client->requestBuffer; | |||
2675 | int result = Success0, j; | |||
2676 | PanoramiXRes *pict; | |||
2677 | ||||
2678 | REQUEST_AT_LEAST_SIZE(xRenderSetPictureTransformReq)if ((sizeof(xRenderSetPictureTransformReq) >> 2) > client ->req_len ) return(16); | |||
2679 | ||||
2680 | VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess){ int rc = dixLookupResourceByType((void **)&(pict), stuff ->picture, XRT_PICTURE, client, (1<<1)); if (rc != 0 ) return rc;}; | |||
2681 | ||||
2682 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2683 | stuff->picture = pict->info[j].id; | |||
2684 | result = | |||
2685 | (*PanoramiXSaveRenderVector[X_RenderSetPictureTransform28]) (client); | |||
2686 | if (result != Success0) | |||
2687 | break; | |||
2688 | } | |||
2689 | ||||
2690 | return result; | |||
2691 | } | |||
2692 | ||||
2693 | static int | |||
2694 | PanoramiXRenderSetPictureFilter(ClientPtr client) | |||
2695 | { | |||
2696 | REQUEST(xRenderSetPictureFilterReq)xRenderSetPictureFilterReq *stuff = (xRenderSetPictureFilterReq *)client->requestBuffer; | |||
2697 | int result = Success0, j; | |||
2698 | PanoramiXRes *pict; | |||
2699 | ||||
2700 | REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq)if ((sizeof(xRenderSetPictureFilterReq) >> 2) > client ->req_len ) return(16); | |||
2701 | ||||
2702 | VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess){ int rc = dixLookupResourceByType((void **)&(pict), stuff ->picture, XRT_PICTURE, client, (1<<1)); if (rc != 0 ) return rc;}; | |||
2703 | ||||
2704 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2705 | stuff->picture = pict->info[j].id; | |||
2706 | result = | |||
2707 | (*PanoramiXSaveRenderVector[X_RenderSetPictureFilter30]) (client); | |||
2708 | if (result != Success0) | |||
2709 | break; | |||
2710 | } | |||
2711 | ||||
2712 | return result; | |||
2713 | } | |||
2714 | ||||
2715 | static int | |||
2716 | PanoramiXRenderFreePicture(ClientPtr client) | |||
2717 | { | |||
2718 | PanoramiXRes *pict; | |||
2719 | int result = Success0, j; | |||
2720 | ||||
2721 | REQUEST(xRenderFreePictureReq)xRenderFreePictureReq *stuff = (xRenderFreePictureReq *)client ->requestBuffer; | |||
2722 | ||||
2723 | REQUEST_SIZE_MATCH(xRenderFreePictureReq)if ((sizeof(xRenderFreePictureReq) >> 2) != client-> req_len) return(16); | |||
2724 | ||||
2725 | client->errorValue = stuff->picture; | |||
2726 | ||||
2727 | VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixDestroyAccess){ int rc = dixLookupResourceByType((void **)&(pict), stuff ->picture, XRT_PICTURE, client, (1<<2)); if (rc != 0 ) return rc;}; | |||
2728 | ||||
2729 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
2730 | stuff->picture = pict->info[j].id; | |||
2731 | result = (*PanoramiXSaveRenderVector[X_RenderFreePicture7]) (client); | |||
2732 | if (result != Success0) | |||
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 = Success0, j; | |||
2747 | xRenderCompositeReq orig; | |||
2748 | ||||
2749 | REQUEST(xRenderCompositeReq)xRenderCompositeReq *stuff = (xRenderCompositeReq *)client-> requestBuffer; | |||
2750 | ||||
2751 | REQUEST_SIZE_MATCH(xRenderCompositeReq)if ((sizeof(xRenderCompositeReq) >> 2) != client->req_len ) return(16); | |||
2752 | ||||
2753 | VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess){ int rc = dixLookupResourceByType((void **)&(src), stuff ->src, XRT_PICTURE, client, (1<<0)); if (rc != 0) return rc;}; | |||
2754 | VERIFY_XIN_ALPHA(msk, stuff->mask, client, DixReadAccess){ if (stuff->mask == 0L) msk = 0; else { { int rc = dixLookupResourceByType ((void **)&(msk), stuff->mask, XRT_PICTURE, client, (1 <<0)); if (rc != 0) return rc;}; } }; | |||
2755 | VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess){ int rc = dixLookupResourceByType((void **)&(dst), stuff ->dst, XRT_PICTURE, client, (1<<1)); if (rc != 0) return rc;}; | |||
2756 | ||||
2757 | orig = *stuff; | |||
2758 | ||||
2759 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; 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_RenderComposite8]) (client); | |||
2778 | if (result != Success0) | |||
2779 | break; | |||
2780 | } | |||
2781 | ||||
2782 | return result; | |||
2783 | } | |||
2784 | ||||
2785 | static int | |||
2786 | PanoramiXRenderCompositeGlyphs(ClientPtr client) | |||
2787 | { | |||
2788 | PanoramiXRes *src, *dst; | |||
2789 | int result = Success0, j; | |||
2790 | ||||
2791 | REQUEST(xRenderCompositeGlyphsReq)xRenderCompositeGlyphsReq *stuff = (xRenderCompositeGlyphsReq *)client->requestBuffer; | |||
2792 | xGlyphElt origElt, *elt; | |||
2793 | INT16 xSrc, ySrc; | |||
2794 | ||||
2795 | REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq)if ((sizeof(xRenderCompositeGlyphsReq) >> 2) > client ->req_len ) return(16); | |||
2796 | VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess){ int rc = dixLookupResourceByType((void **)&(src), stuff ->src, XRT_PICTURE, client, (1<<0)); if (rc != 0) return rc;}; | |||
2797 | VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess){ int rc = dixLookupResourceByType((void **)&(dst), stuff ->dst, XRT_PICTURE, client, (1<<1)); if (rc != 0) return rc;}; | |||
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)for(j = 0; j < PanoramiXNumScreens; 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 != Success0) | |||
2819 | break; | |||
2820 | } | |||
2821 | } | |||
2822 | ||||
2823 | return result; | |||
2824 | } | |||
2825 | ||||
2826 | static int | |||
2827 | PanoramiXRenderFillRectangles(ClientPtr client) | |||
2828 | { | |||
2829 | PanoramiXRes *dst; | |||
2830 | int result = Success0, j; | |||
2831 | ||||
2832 | REQUEST(xRenderFillRectanglesReq)xRenderFillRectanglesReq *stuff = (xRenderFillRectanglesReq * )client->requestBuffer; | |||
2833 | char *extra; | |||
2834 | int extra_len; | |||
2835 | ||||
2836 | REQUEST_AT_LEAST_SIZE(xRenderFillRectanglesReq)if ((sizeof(xRenderFillRectanglesReq) >> 2) > client ->req_len ) return(16); | |||
2837 | VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess){ int rc = dixLookupResourceByType((void **)&(dst), stuff ->dst, XRT_PICTURE, client, (1<<1)); if (rc != 0) return rc;}; | |||
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)__builtin___memcpy_chk (extra, stuff + 1, extra_len, __builtin_object_size (extra, 0)); | |||
2841 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
2842 | if (j) | |||
2843 | memcpy(stuff + 1, extra, extra_len)__builtin___memcpy_chk (stuff + 1, extra, extra_len, __builtin_object_size (stuff + 1, 0)); | |||
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_RenderFillRectangles26]) (client); | |||
2862 | if (result != Success0) | |||
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 = Success0, j; | |||
2876 | ||||
2877 | REQUEST(xRenderTrapezoidsReq)xRenderTrapezoidsReq *stuff = (xRenderTrapezoidsReq *)client-> requestBuffer; | |||
2878 | char *extra; | |||
2879 | int extra_len; | |||
2880 | ||||
2881 | REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq)if ((sizeof(xRenderTrapezoidsReq) >> 2) > client-> req_len ) return(16); | |||
2882 | ||||
2883 | VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess){ int rc = dixLookupResourceByType((void **)&(src), stuff ->src, XRT_PICTURE, client, (1<<0)); if (rc != 0) return rc;}; | |||
2884 | VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess){ int rc = dixLookupResourceByType((void **)&(dst), stuff ->dst, XRT_PICTURE, client, (1<<1)); if (rc != 0) return rc;}; | |||
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)__builtin___memcpy_chk (extra, stuff + 1, extra_len, __builtin_object_size (extra, 0)); | |||
2890 | ||||
2891 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
2892 | if (j) | |||
2893 | memcpy(stuff + 1, extra, extra_len)__builtin___memcpy_chk (stuff + 1, extra, extra_len, __builtin_object_size (stuff + 1, 0)); | |||
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_RenderTrapezoids10]) (client); | |||
2921 | ||||
2922 | if (result != Success0) | |||
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 = Success0, j; | |||
2937 | ||||
2938 | REQUEST(xRenderTrianglesReq)xRenderTrianglesReq *stuff = (xRenderTrianglesReq *)client-> requestBuffer; | |||
2939 | char *extra; | |||
2940 | int extra_len; | |||
2941 | ||||
2942 | REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq)if ((sizeof(xRenderTrianglesReq) >> 2) > client-> req_len ) return(16); | |||
2943 | ||||
2944 | VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess){ int rc = dixLookupResourceByType((void **)&(src), stuff ->src, XRT_PICTURE, client, (1<<0)); if (rc != 0) return rc;}; | |||
2945 | VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess){ int rc = dixLookupResourceByType((void **)&(dst), stuff ->dst, XRT_PICTURE, client, (1<<1)); if (rc != 0) return rc;}; | |||
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)__builtin___memcpy_chk (extra, stuff + 1, extra_len, __builtin_object_size (extra, 0)); | |||
2951 | ||||
2952 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
2953 | if (j) | |||
2954 | memcpy(stuff + 1, extra, extra_len)__builtin___memcpy_chk (stuff + 1, extra, extra_len, __builtin_object_size (stuff + 1, 0)); | |||
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_RenderTriangles11]) (client); | |||
2978 | ||||
2979 | if (result != Success0) | |||
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 = Success0, j; | |||
2994 | ||||
2995 | REQUEST(xRenderTriStripReq)xRenderTriStripReq *stuff = (xRenderTriStripReq *)client-> requestBuffer; | |||
2996 | char *extra; | |||
2997 | int extra_len; | |||
2998 | ||||
2999 | REQUEST_AT_LEAST_SIZE(xRenderTriStripReq)if ((sizeof(xRenderTriStripReq) >> 2) > client->req_len ) return(16); | |||
3000 | ||||
3001 | VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess){ int rc = dixLookupResourceByType((void **)&(src), stuff ->src, XRT_PICTURE, client, (1<<0)); if (rc != 0) return rc;}; | |||
3002 | VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess){ int rc = dixLookupResourceByType((void **)&(dst), stuff ->dst, XRT_PICTURE, client, (1<<1)); if (rc != 0) return rc;}; | |||
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)__builtin___memcpy_chk (extra, stuff + 1, extra_len, __builtin_object_size (extra, 0)); | |||
3008 | ||||
3009 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
3010 | if (j) | |||
3011 | memcpy(stuff + 1, extra, extra_len)__builtin___memcpy_chk (stuff + 1, extra, extra_len, __builtin_object_size (stuff + 1, 0)); | |||
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_RenderTriStrip12]) (client); | |||
3031 | ||||
3032 | if (result != Success0) | |||
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 = Success0, j; | |||
3047 | ||||
3048 | REQUEST(xRenderTriFanReq)xRenderTriFanReq *stuff = (xRenderTriFanReq *)client->requestBuffer; | |||
3049 | char *extra; | |||
3050 | int extra_len; | |||
3051 | ||||
3052 | REQUEST_AT_LEAST_SIZE(xRenderTriFanReq)if ((sizeof(xRenderTriFanReq) >> 2) > client->req_len ) return(16); | |||
3053 | ||||
3054 | VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess){ int rc = dixLookupResourceByType((void **)&(src), stuff ->src, XRT_PICTURE, client, (1<<0)); if (rc != 0) return rc;}; | |||
3055 | VERIFY_XIN_PICTURE(dst, stuff->dst, client, DixWriteAccess){ int rc = dixLookupResourceByType((void **)&(dst), stuff ->dst, XRT_PICTURE, client, (1<<1)); if (rc != 0) return rc;}; | |||
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)__builtin___memcpy_chk (extra, stuff + 1, extra_len, __builtin_object_size (extra, 0)); | |||
3061 | ||||
3062 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
3063 | if (j) | |||
3064 | memcpy(stuff + 1, extra, extra_len)__builtin___memcpy_chk (stuff + 1, extra, extra_len, __builtin_object_size (stuff + 1, 0)); | |||
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_RenderTriFan13]) (client); | |||
3084 | ||||
3085 | if (result != Success0) | |||
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 = Success0, j; | |||
3100 | ||||
3101 | REQUEST(xRenderAddTrapsReq)xRenderAddTrapsReq *stuff = (xRenderAddTrapsReq *)client-> requestBuffer; | |||
3102 | char *extra; | |||
3103 | int extra_len; | |||
3104 | INT16 x_off, y_off; | |||
3105 | ||||
3106 | REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq)if ((sizeof(xRenderAddTrapsReq) >> 2) > client->req_len ) return(16); | |||
3107 | VERIFY_XIN_PICTURE(picture, stuff->picture, client, DixWriteAccess){ int rc = dixLookupResourceByType((void **)&(picture), stuff ->picture, XRT_PICTURE, client, (1<<1)); if (rc != 0 ) return rc;}; | |||
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)__builtin___memcpy_chk (extra, stuff + 1, extra_len, __builtin_object_size (extra, 0)); | |||
3111 | x_off = stuff->xOff; | |||
3112 | y_off = stuff->yOff; | |||
3113 | FOR_NSCREENS_FORWARD(j)for(j = 0; j < PanoramiXNumScreens; j++) { | |||
3114 | if (j) | |||
3115 | memcpy(stuff + 1, extra, extra_len)__builtin___memcpy_chk (stuff + 1, extra, extra_len, __builtin_object_size (stuff + 1, 0)); | |||
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_RenderAddTraps32]) (client); | |||
3123 | if (result != Success0) | |||
3124 | break; | |||
3125 | } | |||
3126 | free(extra); | |||
3127 | } | |||
3128 | ||||
3129 | return result; | |||
3130 | } | |||
3131 | ||||
3132 | static int | |||
3133 | PanoramiXRenderCreateSolidFill(ClientPtr client) | |||
3134 | { | |||
3135 | REQUEST(xRenderCreateSolidFillReq)xRenderCreateSolidFillReq *stuff = (xRenderCreateSolidFillReq *)client->requestBuffer; | |||
3136 | PanoramiXRes *newPict; | |||
3137 | int result = Success0, j; | |||
3138 | ||||
3139 | REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq)if ((sizeof(xRenderCreateSolidFillReq) >> 2) > client ->req_len ) return(16); | |||
3140 | ||||
3141 | if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) | |||
3142 | return BadAlloc11; | |||
3143 | ||||
3144 | newPict->type = XRT_PICTURE; | |||
3145 | panoramix_setup_ids(newPict, client, stuff->pid); | |||
3146 | newPict->u.pict.root = FALSE0; | |||
3147 | ||||
3148 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
3149 | stuff->pid = newPict->info[j].id; | |||
3150 | result = (*PanoramiXSaveRenderVector[X_RenderCreateSolidFill33]) (client); | |||
3151 | if (result != Success0) | |||
3152 | break; | |||
3153 | } | |||
3154 | ||||
3155 | if (result == Success0) | |||
3156 | AddResourceDarwin_X_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)xRenderCreateLinearGradientReq *stuff = (xRenderCreateLinearGradientReq *)client->requestBuffer; | |||
3167 | PanoramiXRes *newPict; | |||
3168 | int result = Success0, j; | |||
3169 | ||||
3170 | REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq)if ((sizeof(xRenderCreateLinearGradientReq) >> 2) > client ->req_len ) return(16); | |||
3171 | ||||
3172 | if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) | |||
3173 | return BadAlloc11; | |||
3174 | ||||
3175 | newPict->type = XRT_PICTURE; | |||
3176 | panoramix_setup_ids(newPict, client, stuff->pid); | |||
3177 | newPict->u.pict.root = FALSE0; | |||
3178 | ||||
3179 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
3180 | stuff->pid = newPict->info[j].id; | |||
3181 | result = | |||
3182 | (*PanoramiXSaveRenderVector[X_RenderCreateLinearGradient34]) (client); | |||
3183 | if (result != Success0) | |||
3184 | break; | |||
3185 | } | |||
3186 | ||||
3187 | if (result == Success0) | |||
3188 | AddResourceDarwin_X_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)xRenderCreateRadialGradientReq *stuff = (xRenderCreateRadialGradientReq *)client->requestBuffer; | |||
3199 | PanoramiXRes *newPict; | |||
3200 | int result = Success0, j; | |||
3201 | ||||
3202 | REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq)if ((sizeof(xRenderCreateRadialGradientReq) >> 2) > client ->req_len ) return(16); | |||
3203 | ||||
3204 | if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) | |||
3205 | return BadAlloc11; | |||
3206 | ||||
3207 | newPict->type = XRT_PICTURE; | |||
3208 | panoramix_setup_ids(newPict, client, stuff->pid); | |||
3209 | newPict->u.pict.root = FALSE0; | |||
3210 | ||||
3211 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
3212 | stuff->pid = newPict->info[j].id; | |||
3213 | result = | |||
3214 | (*PanoramiXSaveRenderVector[X_RenderCreateRadialGradient35]) (client); | |||
3215 | if (result != Success0) | |||
3216 | break; | |||
3217 | } | |||
3218 | ||||
3219 | if (result == Success0) | |||
3220 | AddResourceDarwin_X_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)xRenderCreateConicalGradientReq *stuff = (xRenderCreateConicalGradientReq *)client->requestBuffer; | |||
3231 | PanoramiXRes *newPict; | |||
3232 | int result = Success0, j; | |||
3233 | ||||
3234 | REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq)if ((sizeof(xRenderCreateConicalGradientReq) >> 2) > client->req_len ) return(16); | |||
3235 | ||||
3236 | if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) | |||
3237 | return BadAlloc11; | |||
3238 | ||||
3239 | newPict->type = XRT_PICTURE; | |||
3240 | panoramix_setup_ids(newPict, client, stuff->pid); | |||
3241 | newPict->u.pict.root = FALSE0; | |||
3242 | ||||
3243 | FOR_NSCREENS_BACKWARD(j)for(j = PanoramiXNumScreens - 1; j >= 0; j--) { | |||
3244 | stuff->pid = newPict->info[j].id; | |||
3245 | result = | |||
3246 | (*PanoramiXSaveRenderVector[X_RenderCreateConicalGradient36]) | |||
3247 | (client); | |||
3248 | if (result != Success0) | |||
3249 | break; | |||
3250 | } | |||
3251 | ||||
3252 | if (result == Success0) | |||
3253 | AddResourceDarwin_X_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 + BadPicture1); | |||
3269 | for (i = 0; i < RenderNumberRequests(36 +1); i++) | |||
3270 | PanoramiXSaveRenderVector[i] = ProcRenderVector[i]; | |||
3271 | /* | |||
3272 | * Stuff in Xinerama aware request processing hooks | |||
3273 | */ | |||
3274 | ProcRenderVector[X_RenderCreatePicture4] = PanoramiXRenderCreatePicture; | |||
3275 | ProcRenderVector[X_RenderChangePicture5] = PanoramiXRenderChangePicture; | |||
3276 | ProcRenderVector[X_RenderSetPictureTransform28] = | |||
3277 | PanoramiXRenderSetPictureTransform; | |||
3278 | ProcRenderVector[X_RenderSetPictureFilter30] = | |||
3279 | PanoramiXRenderSetPictureFilter; | |||
3280 | ProcRenderVector[X_RenderSetPictureClipRectangles6] = | |||
3281 | PanoramiXRenderSetPictureClipRectangles; | |||
3282 | ProcRenderVector[X_RenderFreePicture7] = PanoramiXRenderFreePicture; | |||
3283 | ProcRenderVector[X_RenderComposite8] = PanoramiXRenderComposite; | |||
3284 | ProcRenderVector[X_RenderCompositeGlyphs823] = PanoramiXRenderCompositeGlyphs; | |||
3285 | ProcRenderVector[X_RenderCompositeGlyphs1624] = | |||
3286 | PanoramiXRenderCompositeGlyphs; | |||
3287 | ProcRenderVector[X_RenderCompositeGlyphs3225] = | |||
3288 | PanoramiXRenderCompositeGlyphs; | |||
3289 | ProcRenderVector[X_RenderFillRectangles26] = PanoramiXRenderFillRectangles; | |||
3290 | ||||
3291 | ProcRenderVector[X_RenderTrapezoids10] = PanoramiXRenderTrapezoids; | |||
3292 | ProcRenderVector[X_RenderTriangles11] = PanoramiXRenderTriangles; | |||
3293 | ProcRenderVector[X_RenderTriStrip12] = PanoramiXRenderTriStrip; | |||
3294 | ProcRenderVector[X_RenderTriFan13] = PanoramiXRenderTriFan; | |||
3295 | ProcRenderVector[X_RenderAddTraps32] = PanoramiXRenderAddTraps; | |||
3296 | ||||
3297 | ProcRenderVector[X_RenderCreateSolidFill33] = PanoramiXRenderCreateSolidFill; | |||
3298 | ProcRenderVector[X_RenderCreateLinearGradient34] = | |||
3299 | PanoramiXRenderCreateLinearGradient; | |||
3300 | ProcRenderVector[X_RenderCreateRadialGradient35] = | |||
3301 | PanoramiXRenderCreateRadialGradient; | |||
3302 | ProcRenderVector[X_RenderCreateConicalGradient36] = | |||
3303 | PanoramiXRenderCreateConicalGradient; | |||
3304 | } | |||
3305 | ||||
3306 | void | |||
3307 | PanoramiXRenderReset(void) | |||
3308 | { | |||
3309 | int i; | |||
3310 | ||||
3311 | for (i = 0; i < RenderNumberRequests(36 +1); i++) | |||
3312 | ProcRenderVector[i] = PanoramiXSaveRenderVector[i]; | |||
3313 | RenderErrBase = 0; | |||
3314 | } | |||
3315 | ||||
3316 | #endif /* PANORAMIX */ |