mirror of OpenBSD xenocara tree
github.com/openbsd/xenocara
openbsd
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_CONFIG_H
26#include <config.h>
27#endif
28#include "Xrenderint.h"
29
30/* precompute the maximum size of batching request allowed */
31
32#define size (SIZEOF(xRenderFillRectanglesReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
33
34void
35XRenderFillRectangles (Display *dpy,
36 int op,
37 Picture dst,
38 _Xconst XRenderColor *color,
39 _Xconst XRectangle *rectangles,
40 int n_rects)
41{
42 XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
43 xRenderFillRectanglesReq *req;
44
45 RenderSimpleCheckExtension (dpy, info);
46 LockDisplay(dpy);
47
48 while (n_rects)
49 {
50 long len;
51 int n;
52
53 GetReq(RenderFillRectangles, req);
54
55 req->reqType = (CARD8) info->codes->major_opcode;
56 req->renderReqType = X_RenderFillRectangles;
57 req->op = (CARD8) op;
58 req->dst = (CARD32) dst;
59 req->color.red = color->red;
60 req->color.green = color->green;
61 req->color.blue = color->blue;
62 req->color.alpha = color->alpha;
63
64 n = n_rects;
65 len = ((long)n) << 1;
66 if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length))
67 {
68 n = (int) ((dpy->max_request_size - req->length) >> 1);
69 len = ((long)n) << 1;
70 }
71 SetReqLen(req, len, len);
72 len <<= 2; /* watch out for macros... */
73 Data16 (dpy, (_Xconst short *) rectangles, len);
74 n_rects -= n;
75 rectangles += n;
76 }
77 UnlockDisplay(dpy);
78 SyncHandle();
79}
80