11f0ac6a5Smrg/*
21f0ac6a5Smrg *
31f0ac6a5Smrg * Copyright © 2002 Keith Packard
41f0ac6a5Smrg *
51f0ac6a5Smrg * Permission to use, copy, modify, distribute, and sell this software and its
61f0ac6a5Smrg * documentation for any purpose is hereby granted without fee, provided that
71f0ac6a5Smrg * the above copyright notice appear in all copies and that both that
81f0ac6a5Smrg * copyright notice and this permission notice appear in supporting
91f0ac6a5Smrg * documentation, and that the name of Keith Packard not be used in
101f0ac6a5Smrg * advertising or publicity pertaining to distribution of the software without
111f0ac6a5Smrg * specific, written prior permission.  Keith Packard makes no
121f0ac6a5Smrg * representations about the suitability of this software for any purpose.  It
131f0ac6a5Smrg * is provided "as is" without express or implied warranty.
141f0ac6a5Smrg *
151f0ac6a5Smrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
161f0ac6a5Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
171f0ac6a5Smrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
181f0ac6a5Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
191f0ac6a5Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
201f0ac6a5Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
211f0ac6a5Smrg * PERFORMANCE OF THIS SOFTWARE.
221f0ac6a5Smrg */
231f0ac6a5Smrg
241f0ac6a5Smrg#ifdef HAVE_CONFIG_H
251f0ac6a5Smrg#include <config.h>
261f0ac6a5Smrg#endif
271f0ac6a5Smrg#include "Xrenderint.h"
281f0ac6a5Smrg
291f0ac6a5Smrgvoid
301f0ac6a5SmrgXRenderCompositeTrapezoids (Display		*dpy,
311f0ac6a5Smrg			    int			op,
321f0ac6a5Smrg			    Picture		src,
331f0ac6a5Smrg			    Picture		dst,
341f0ac6a5Smrg			    _Xconst XRenderPictFormat	*maskFormat,
351f0ac6a5Smrg			    int			xSrc,
361f0ac6a5Smrg			    int			ySrc,
371f0ac6a5Smrg			    _Xconst XTrapezoid	*traps,
381f0ac6a5Smrg			    int			ntrap)
391f0ac6a5Smrg{
40d21ab8bcSmrg    XRenderExtDisplayInfo   *info = XRenderFindDisplay (dpy);
411f0ac6a5Smrg    unsigned long	    max_req = dpy->bigreq_size ? dpy->bigreq_size : dpy->max_request_size;
421f0ac6a5Smrg
431f0ac6a5Smrg    RenderSimpleCheckExtension (dpy, info);
441f0ac6a5Smrg    LockDisplay(dpy);
451f0ac6a5Smrg    while (ntrap)
461f0ac6a5Smrg    {
47d21ab8bcSmrg	xRenderTrapezoidsReq	*req;
48d21ab8bcSmrg	int			n;
49d21ab8bcSmrg	unsigned long		len;
50d21ab8bcSmrg
511f0ac6a5Smrg	GetReq(RenderTrapezoids, req);
52d21ab8bcSmrg	req->reqType = (CARD8) info->codes->major_opcode;
531f0ac6a5Smrg	req->renderReqType = X_RenderTrapezoids;
541f0ac6a5Smrg	req->op = (CARD8) op;
55d21ab8bcSmrg	req->src = (CARD32) src;
56d21ab8bcSmrg	req->dst = (CARD32) dst;
57d21ab8bcSmrg	req->maskFormat = (CARD32) (maskFormat ? maskFormat->id : 0);
58d21ab8bcSmrg	req->xSrc = (INT16) xSrc;
59d21ab8bcSmrg	req->ySrc = (INT16) ySrc;
601f0ac6a5Smrg	n = ntrap;
61d21ab8bcSmrg	len = ((unsigned long) n) * (SIZEOF (xTrapezoid) >> 2);
621f0ac6a5Smrg	if (len > (max_req - req->length)) {
63d21ab8bcSmrg	    n = (int) ((max_req - req->length) / (SIZEOF (xTrapezoid) >> 2));
64d21ab8bcSmrg	    len = ((unsigned long) n) * (SIZEOF (xTrapezoid) >> 2);
651f0ac6a5Smrg	}
661f0ac6a5Smrg	SetReqLen (req, len, len);
671f0ac6a5Smrg	len <<= 2;
68d21ab8bcSmrg	DataInt32 (dpy, (_Xconst int *) traps, len);
691f0ac6a5Smrg	ntrap -= n;
701f0ac6a5Smrg	traps += n;
711f0ac6a5Smrg    }
721f0ac6a5Smrg    UnlockDisplay(dpy);
731f0ac6a5Smrg    SyncHandle();
741f0ac6a5Smrg}
751f0ac6a5Smrg
76