Imported Upstream version 0.9.7
[platform/upstream/libXrender.git] / src / FillRects.c
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
34 void
35 XRenderFillRectangles (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     long                        len;
45     int                         n;
46
47     RenderSimpleCheckExtension (dpy, info);
48     LockDisplay(dpy);
49
50     while (n_rects)
51     {
52         GetReq(RenderFillRectangles, req);
53
54         req->reqType = info->codes->major_opcode;
55         req->renderReqType = X_RenderFillRectangles;
56         req->op = op;
57         req->dst = dst;
58         req->color.red = color->red;
59         req->color.green = color->green;
60         req->color.blue = color->blue;
61         req->color.alpha = color->alpha;
62
63         n = n_rects;
64         len = ((long)n) << 1;
65         if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length))
66         {
67             n = (dpy->max_request_size - req->length) >> 1;
68             len = ((long)n) << 1;
69         }
70         SetReqLen(req, len, len);
71         len <<= 2; /* watch out for macros... */
72         Data16 (dpy, (short *) rectangles, len);
73         n_rects -= n;
74         rectangles += n;
75     }
76     UnlockDisplay(dpy);
77     SyncHandle();
78 }
79