DrRect.c revision 61b2299d
11ab64890Smrg/* $Xorg: DrRect.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */ 21ab64890Smrg/* 31ab64890Smrg 41ab64890SmrgCopyright 1986, 1998 The Open Group 51ab64890Smrg 61ab64890SmrgPermission to use, copy, modify, distribute, and sell this software and its 71ab64890Smrgdocumentation for any purpose is hereby granted without fee, provided that 81ab64890Smrgthe above copyright notice appear in all copies and that both that 91ab64890Smrgcopyright notice and this permission notice appear in supporting 101ab64890Smrgdocumentation. 111ab64890Smrg 121ab64890SmrgThe above copyright notice and this permission notice shall be included in 131ab64890Smrgall copies or substantial portions of the Software. 141ab64890Smrg 151ab64890SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 161ab64890SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 171ab64890SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 181ab64890SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 191ab64890SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 201ab64890SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 211ab64890Smrg 221ab64890SmrgExcept as contained in this notice, the name of The Open Group shall not be 231ab64890Smrgused in advertising or otherwise to promote the sale, use or other dealings 241ab64890Smrgin this Software without prior written authorization from The Open Group. 251ab64890Smrg 261ab64890Smrg*/ 271ab64890Smrg/* $XFree86: xc/lib/X11/DrRect.c,v 1.3 2001/01/17 19:41:34 dawes Exp $ */ 281ab64890Smrg 291ab64890Smrg#ifdef HAVE_CONFIG_H 301ab64890Smrg#include <config.h> 311ab64890Smrg#endif 321ab64890Smrg#include "Xlibint.h" 331ab64890Smrg 341ab64890Smrg/* precompute the maximum size of batching request allowed */ 351ab64890Smrg 361ab64890Smrg#define wsize (SIZEOF(xPolyRectangleReq) + WRCTSPERBATCH * SIZEOF(xRectangle)) 371ab64890Smrg#define zsize (SIZEOF(xPolyRectangleReq) + ZRCTSPERBATCH * SIZEOF(xRectangle)) 381ab64890Smrg 391ab64890Smrgint 401ab64890SmrgXDrawRectangle( 411ab64890Smrg register Display *dpy, 421ab64890Smrg Drawable d, 431ab64890Smrg GC gc, 4461b2299dSmrg int x, 451ab64890Smrg int y, /* INT16 */ 461ab64890Smrg unsigned int width, 471ab64890Smrg unsigned int height) /* CARD16 */ 481ab64890Smrg{ 491ab64890Smrg xRectangle *rect; 501ab64890Smrg#ifdef MUSTCOPY 511ab64890Smrg xRectangle rectdata; 521ab64890Smrg long len = SIZEOF(xRectangle); 531ab64890Smrg 541ab64890Smrg rect = &rectdata; 551ab64890Smrg#endif /* MUSTCOPY */ 561ab64890Smrg 571ab64890Smrg LockDisplay(dpy); 581ab64890Smrg FlushGC(dpy, gc); 591ab64890Smrg 601ab64890Smrg { 611ab64890Smrg register xPolyRectangleReq *req = (xPolyRectangleReq *) dpy->last_req; 621ab64890Smrg 631ab64890Smrg /* if same as previous request, with same drawable, batch requests */ 641ab64890Smrg if ( 651ab64890Smrg (req->reqType == X_PolyRectangle) 661ab64890Smrg && (req->drawable == d) 671ab64890Smrg && (req->gc == gc->gid) 681ab64890Smrg && ((dpy->bufptr + SIZEOF(xRectangle)) <= dpy->bufmax) 691ab64890Smrg && (((char *)dpy->bufptr - (char *)req) < (gc->values.line_width ? 701ab64890Smrg wsize : zsize)) ) { 711ab64890Smrg req->length += SIZEOF(xRectangle) >> 2; 721ab64890Smrg#ifndef MUSTCOPY 731ab64890Smrg rect = (xRectangle *) dpy->bufptr; 741ab64890Smrg dpy->bufptr += SIZEOF(xRectangle); 751ab64890Smrg#endif /* not MUSTCOPY */ 761ab64890Smrg } 771ab64890Smrg 781ab64890Smrg else { 791ab64890Smrg GetReqExtra(PolyRectangle, SIZEOF(xRectangle), req); 801ab64890Smrg req->drawable = d; 811ab64890Smrg req->gc = gc->gid; 821ab64890Smrg#ifdef MUSTCOPY 831ab64890Smrg dpy->bufptr -= SIZEOF(xRectangle); 841ab64890Smrg#else 851ab64890Smrg rect = (xRectangle *) NEXTPTR(req,xPolyRectangleReq); 861ab64890Smrg#endif /* MUSTCOPY */ 871ab64890Smrg } 881ab64890Smrg 891ab64890Smrg rect->x = x; 901ab64890Smrg rect->y = y; 911ab64890Smrg rect->width = width; 921ab64890Smrg rect->height = height; 931ab64890Smrg 941ab64890Smrg#ifdef MUSTCOPY 951ab64890Smrg Data (dpy, (char *) rect, len); /* subtracted bufptr up above */ 961ab64890Smrg#endif /* MUSTCOPY */ 971ab64890Smrg 981ab64890Smrg } 991ab64890Smrg UnlockDisplay(dpy); 1001ab64890Smrg SyncHandle(); 1011ab64890Smrg return 1; 1021ab64890Smrg} 103