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