AddTrap.c revision 1f0ac6a5
1/*
2 * $Id: AddTrap.c,v 1.1.1.1 2008/07/30 02:56:06 mrg Exp $
3 *
4 * Copyright © 2004 Keith Packard
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission.  Keith Packard makes no
13 * representations about the suitability of this software for any purpose.  It
14 * is provided "as is" without express or implied warranty.
15 *
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
23 */
24
25#ifdef HAVE_CONFIG_H
26#include <config.h>
27#endif
28#include "Xrenderint.h"
29
30#define NLOCAL	256
31
32void
33XRenderAddTraps (Display	    *dpy,
34		 Picture	    picture,
35		 int		    xOff,
36		 int		    yOff,
37		 _Xconst XTrap	    *traps,
38		 int		    ntrap)
39{
40    XRenderExtDisplayInfo   *info = XRenderFindDisplay (dpy);
41    xRenderAddTrapsReq	    *req;
42    int			    n;
43    long    		    len;
44    unsigned long	    max_req = dpy->bigreq_size ? dpy->bigreq_size : dpy->max_request_size;
45
46    RenderSimpleCheckExtension (dpy, info);
47    LockDisplay(dpy);
48    while (ntrap)
49    {
50	GetReq(RenderAddTraps, req);
51	req->reqType = info->codes->major_opcode;
52	req->renderReqType = X_RenderAddTraps;
53	req->picture = picture;
54	req->xOff = xOff;
55	req->yOff = yOff;
56	n = ntrap;
57	len = ((long) n) * (SIZEOF (xTrap) >> 2);
58	if (len > (max_req - req->length)) {
59	    n = (max_req - req->length) / (SIZEOF (xTrap) >> 2);
60	    len = ((long)n) * (SIZEOF (xTrap) >> 2);
61	}
62	SetReqLen (req, len, len);
63	len <<= 2;
64	DataInt32 (dpy, (int *) traps, len);
65	ntrap -= n;
66	traps += n;
67    }
68    UnlockDisplay(dpy);
69    SyncHandle();
70}
71