3 * Copyright © 2000 SuSE, Inc.
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of SuSE not be used in advertising or
10 * publicity pertaining to distribution of the software without specific,
11 * written prior permission. SuSE makes no representations about the
12 * suitability of this software for any purpose. It is provided "as is"
13 * without express or implied warranty.
15 * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
17 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
19 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 * Author: Keith Packard, SuSE, Inc.
28 #include "Xrenderint.h"
29 #include <X11/Xregion.h>
32 _XRenderProcessPictureAttributes (Display *dpy,
33 xRenderChangePictureReq *req,
34 unsigned long valuemask,
35 _Xconst XRenderPictureAttributes *attributes)
37 unsigned long values[32];
38 register unsigned long *value = values;
41 if (valuemask & CPRepeat)
42 *value++ = attributes->repeat;
43 if (valuemask & CPAlphaMap)
44 *value++ = attributes->alpha_map;
45 if (valuemask & CPAlphaXOrigin)
46 *value++ = attributes->alpha_x_origin;
47 if (valuemask & CPAlphaYOrigin)
48 *value++ = attributes->alpha_y_origin;
49 if (valuemask & CPClipXOrigin)
50 *value++ = attributes->clip_x_origin;
51 if (valuemask & CPClipYOrigin)
52 *value++ = attributes->clip_y_origin;
53 if (valuemask & CPClipMask)
54 *value++ = attributes->clip_mask;
55 if (valuemask & CPGraphicsExposure)
56 *value++ = attributes->graphics_exposures;
57 if (valuemask & CPSubwindowMode)
58 *value++ = attributes->subwindow_mode;
59 if (valuemask & CPPolyEdge)
60 *value++ = attributes->poly_edge;
61 if (valuemask & CPPolyMode)
62 *value++ = attributes->poly_mode;
63 if (valuemask & CPDither)
64 *value++ = attributes->dither;
65 if (valuemask & CPComponentAlpha)
66 *value++ = attributes->component_alpha;
68 req->length += (nvalues = value - values);
70 nvalues <<= 2; /* watch out for macros... */
71 Data32 (dpy, (long *) values, (long)nvalues);
75 XRenderCreatePicture (Display *dpy,
77 _Xconst XRenderPictFormat *format,
78 unsigned long valuemask,
79 _Xconst XRenderPictureAttributes *attributes)
81 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
83 xRenderCreatePictureReq *req;
85 RenderCheckExtension (dpy, info, 0);
87 GetReq(RenderCreatePicture, req);
88 req->reqType = info->codes->major_opcode;
89 req->renderReqType = X_RenderCreatePicture;
90 req->pid = pid = XAllocID(dpy);
91 req->drawable = drawable;
92 req->format = format->id;
93 if ((req->mask = valuemask))
94 _XRenderProcessPictureAttributes (dpy,
95 (xRenderChangePictureReq *) req,
104 XRenderChangePicture (Display *dpy,
106 unsigned long valuemask,
107 _Xconst XRenderPictureAttributes *attributes)
109 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
110 xRenderChangePictureReq *req;
112 RenderSimpleCheckExtension (dpy, info);
114 GetReq(RenderChangePicture, req);
115 req->reqType = info->codes->major_opcode;
116 req->renderReqType = X_RenderChangePicture;
117 req->picture = picture;
118 req->mask = valuemask;
119 _XRenderProcessPictureAttributes (dpy,
128 _XRenderSetPictureClipRectangles (Display *dpy,
129 XRenderExtDisplayInfo *info,
133 _Xconst XRectangle *rects,
136 xRenderSetPictureClipRectanglesReq *req;
139 GetReq (RenderSetPictureClipRectangles, req);
140 req->reqType = info->codes->major_opcode;
141 req->renderReqType = X_RenderSetPictureClipRectangles;
142 req->picture = picture;
143 req->xOrigin = xOrigin;
144 req->yOrigin = yOrigin;
145 len = ((long) n) << 1;
146 SetReqLen (req, len, 1);
148 Data16 (dpy, (short *) rects, len);
152 XRenderSetPictureClipRectangles (Display *dpy,
156 _Xconst XRectangle *rects,
159 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
161 RenderSimpleCheckExtension (dpy, info);
163 _XRenderSetPictureClipRectangles (dpy, info, picture,
164 xOrigin, yOrigin, rects, n);
170 XRenderSetPictureClipRegion (Display *dpy,
174 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
180 RenderSimpleCheckExtension (dpy, info);
182 total = r->numRects * sizeof (XRectangle);
183 if ((xr = (XRectangle *) _XAllocTemp(dpy, total))) {
184 for (pr = xr, pb = r->rects, i = r->numRects; --i >= 0; pr++, pb++) {
187 pr->width = pb->x2 - pb->x1;
188 pr->height = pb->y2 - pb->y1;
191 if (xr || !r->numRects)
192 _XRenderSetPictureClipRectangles (dpy, info, picture, 0, 0,
195 _XFreeTemp(dpy, (char *)xr, total);
201 XRenderSetPictureTransform (Display *dpy,
203 XTransform *transform)
205 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
206 xRenderSetPictureTransformReq *req;
208 RenderSimpleCheckExtension (dpy, info);
210 GetReq(RenderSetPictureTransform, req);
211 req->reqType = info->codes->major_opcode;
212 req->renderReqType = X_RenderSetPictureTransform;
213 req->picture = picture;
214 req->transform.matrix11 = transform->matrix[0][0];
215 req->transform.matrix12 = transform->matrix[0][1];
216 req->transform.matrix13 = transform->matrix[0][2];
217 req->transform.matrix21 = transform->matrix[1][0];
218 req->transform.matrix22 = transform->matrix[1][1];
219 req->transform.matrix23 = transform->matrix[1][2];
220 req->transform.matrix31 = transform->matrix[2][0];
221 req->transform.matrix32 = transform->matrix[2][1];
222 req->transform.matrix33 = transform->matrix[2][2];
229 XRenderFreePicture (Display *dpy,
232 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
233 xRenderFreePictureReq *req;
235 RenderSimpleCheckExtension (dpy, info);
237 GetReq(RenderFreePicture, req);
238 req->reqType = info->codes->major_opcode;
239 req->renderReqType = X_RenderFreePicture;
240 req->picture = picture;
246 Picture XRenderCreateSolidFill(Display *dpy,
247 const XRenderColor *color)
249 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
251 xRenderCreateSolidFillReq *req;
253 RenderCheckExtension (dpy, info, 0);
255 GetReq(RenderCreateSolidFill, req);
256 req->reqType = info->codes->major_opcode;
257 req->renderReqType = X_RenderCreateSolidFill;
259 req->pid = pid = XAllocID(dpy);
260 req->color.red = color->red;
261 req->color.green = color->green;
262 req->color.blue = color->blue;
263 req->color.alpha = color->alpha;
271 Picture XRenderCreateLinearGradient(Display *dpy,
272 const XLinearGradient *gradient,
274 const XRenderColor *colors,
277 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
279 xRenderCreateLinearGradientReq *req;
282 RenderCheckExtension (dpy, info, 0);
284 GetReq(RenderCreateLinearGradient, req);
285 req->reqType = info->codes->major_opcode;
286 req->renderReqType = X_RenderCreateLinearGradient;
288 req->pid = pid = XAllocID(dpy);
289 req->p1.x = gradient->p1.x;
290 req->p1.y = gradient->p1.y;
291 req->p2.x = gradient->p2.x;
292 req->p2.y = gradient->p2.y;
294 req->nStops = nStops;
295 len = (long) nStops * 3;
296 SetReqLen (req, len, 6);
297 DataInt32(dpy, stops, nStops * 4);
298 Data16(dpy, colors, nStops * 8);
305 Picture XRenderCreateRadialGradient(Display *dpy,
306 const XRadialGradient *gradient,
308 const XRenderColor *colors,
311 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
313 xRenderCreateRadialGradientReq *req;
316 RenderCheckExtension (dpy, info, 0);
318 GetReq(RenderCreateRadialGradient, req);
319 req->reqType = info->codes->major_opcode;
320 req->renderReqType = X_RenderCreateRadialGradient;
322 req->pid = pid = XAllocID(dpy);
323 req->inner.x = gradient->inner.x;
324 req->inner.y = gradient->inner.y;
325 req->outer.x = gradient->outer.x;
326 req->outer.y = gradient->outer.y;
327 req->inner_radius = gradient->inner.radius;
328 req->outer_radius = gradient->outer.radius;
330 req->nStops = nStops;
331 len = (long) nStops * 3;
332 SetReqLen (req, len, 6);
333 DataInt32(dpy, stops, nStops * 4);
334 Data16(dpy, colors, nStops * 8);
341 Picture XRenderCreateConicalGradient(Display *dpy,
342 const XConicalGradient *gradient,
344 const XRenderColor *colors,
347 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
349 xRenderCreateConicalGradientReq *req;
352 RenderCheckExtension (dpy, info, 0);
354 GetReq(RenderCreateConicalGradient, req);
355 req->reqType = info->codes->major_opcode;
356 req->renderReqType = X_RenderCreateConicalGradient;
358 req->pid = pid = XAllocID(dpy);
359 req->center.x = gradient->center.x;
360 req->center.y = gradient->center.y;
361 req->angle = gradient->angle;
363 req->nStops = nStops;
364 len = (long) nStops * 3;
365 SetReqLen (req, len, 6);
366 DataInt32(dpy, stops, nStops * 4);
367 Data16(dpy, colors, nStops * 8);