11f0ac6a5Smrg/*
21f0ac6a5Smrg * Copyright © 2004 Keith Packard
31f0ac6a5Smrg *
41f0ac6a5Smrg * Permission to use, copy, modify, distribute, and sell this software and its
51f0ac6a5Smrg * documentation for any purpose is hereby granted without fee, provided that
61f0ac6a5Smrg * the above copyright notice appear in all copies and that both that
71f0ac6a5Smrg * copyright notice and this permission notice appear in supporting
81f0ac6a5Smrg * documentation, and that the name of Keith Packard not be used in
91f0ac6a5Smrg * advertising or publicity pertaining to distribution of the software without
101f0ac6a5Smrg * specific, written prior permission.  Keith Packard makes no
111f0ac6a5Smrg * representations about the suitability of this software for any purpose.  It
121f0ac6a5Smrg * is provided "as is" without express or implied warranty.
131f0ac6a5Smrg *
141f0ac6a5Smrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
151f0ac6a5Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
161f0ac6a5Smrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
171f0ac6a5Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
181f0ac6a5Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
191f0ac6a5Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
201f0ac6a5Smrg * PERFORMANCE OF THIS SOFTWARE.
211f0ac6a5Smrg */
221f0ac6a5Smrg
231f0ac6a5Smrg#ifdef HAVE_CONFIG_H
241f0ac6a5Smrg#include <config.h>
251f0ac6a5Smrg#endif
261f0ac6a5Smrg#include "Xrenderint.h"
271f0ac6a5Smrg
281f0ac6a5Smrg#define NLOCAL	256
291f0ac6a5Smrg
301f0ac6a5Smrgvoid
311f0ac6a5SmrgXRenderAddTraps (Display	    *dpy,
321f0ac6a5Smrg		 Picture	    picture,
331f0ac6a5Smrg		 int		    xOff,
341f0ac6a5Smrg		 int		    yOff,
351f0ac6a5Smrg		 _Xconst XTrap	    *traps,
361f0ac6a5Smrg		 int		    ntrap)
371f0ac6a5Smrg{
381f0ac6a5Smrg    XRenderExtDisplayInfo   *info = XRenderFindDisplay (dpy);
391f0ac6a5Smrg    unsigned long	    max_req = dpy->bigreq_size ? dpy->bigreq_size : dpy->max_request_size;
401f0ac6a5Smrg
411f0ac6a5Smrg    RenderSimpleCheckExtension (dpy, info);
421f0ac6a5Smrg    LockDisplay(dpy);
431f0ac6a5Smrg    while (ntrap)
441f0ac6a5Smrg    {
45d21ab8bcSmrg	xRenderAddTrapsReq	*req;
46d21ab8bcSmrg	int			n;
47d21ab8bcSmrg	unsigned long		len;
48d21ab8bcSmrg
491f0ac6a5Smrg	GetReq(RenderAddTraps, req);
50d21ab8bcSmrg	req->reqType = (CARD8) info->codes->major_opcode;
511f0ac6a5Smrg	req->renderReqType = X_RenderAddTraps;
52d21ab8bcSmrg	req->picture = (CARD32) picture;
53d21ab8bcSmrg	req->xOff = (INT16) xOff;
54d21ab8bcSmrg	req->yOff = (INT16) yOff;
551f0ac6a5Smrg	n = ntrap;
56d21ab8bcSmrg	len = ((unsigned long) n) * (SIZEOF (xTrap) >> 2);
571f0ac6a5Smrg	if (len > (max_req - req->length)) {
58d21ab8bcSmrg	    n = (int) ((max_req - req->length) / (SIZEOF (xTrap) >> 2));
59d21ab8bcSmrg	    len = ((unsigned long) n) * (SIZEOF (xTrap) >> 2);
601f0ac6a5Smrg	}
611f0ac6a5Smrg	SetReqLen (req, len, len);
621f0ac6a5Smrg	len <<= 2;
63d21ab8bcSmrg	DataInt32 (dpy, (_Xconst int *) traps, (long) len);
641f0ac6a5Smrg	ntrap -= n;
651f0ac6a5Smrg	traps += n;
661f0ac6a5Smrg    }
671f0ac6a5Smrg    UnlockDisplay(dpy);
681f0ac6a5Smrg    SyncHandle();
691f0ac6a5Smrg}
70