do_rects.c revision 264fa531
1/* $Xorg: do_rects.c,v 1.4 2000/08/17 19:54:09 cpqbld Exp $ */ 2/***************************************************************************** 3Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts. 4 5 All Rights Reserved 6 7Permission to use, copy, modify, and distribute this software and its 8documentation for any purpose and without fee is hereby granted, 9provided that the above copyright notice appear in all copies and that 10both that copyright notice and this permission notice appear in 11supporting documentation, and that the name of Digital not be 12used in advertising or publicity pertaining to distribution of the 13software without specific, written prior permission. 14 15DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 16ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 17DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 18ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 19WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 20ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 21SOFTWARE. 22 23******************************************************************************/ 24/* $XFree86: xc/programs/x11perf/do_rects.c,v 1.4 2000/11/29 08:58:19 keithp Exp $ */ 25 26#include "x11perf.h" 27#include "bitmaps.h" 28 29static XRectangle *rects; 30static GC pgc; 31 32int 33InitRectangles(XParms xp, Parms p, int reps) 34{ 35 int i; 36 int size = p->special; 37 int step; 38 int x, y; 39 int rows; 40 int lw = 0; 41 42 pgc = xp->fggc; 43 44 if (p->bfont) 45 { 46 lw = atoi (p->bfont); 47 48 XSetLineAttributes(xp->d, xp->bggc, lw, LineSolid, CapButt, JoinMiter); 49 XSetLineAttributes(xp->d, xp->fggc, lw, LineSolid, CapButt, JoinMiter); 50 lw = (lw >> 1) + 1; 51 } 52 53 rects = (XRectangle *)malloc(p->objects * sizeof(XRectangle)); 54 x = lw; 55 y = lw; 56 rows = 0; 57 if (xp->pack) { 58 /* Pack rectangles as close as possible, mainly for debugging faster 59 tiling, stippling routines in a server */ 60 step = size; 61 } else { 62 /* Try to exercise all alignments...any odd number is okay */ 63 step = size + 1 + (size % 2); 64 } 65 66 for (i = 0; i != p->objects; i++) { 67 rects[i].x = x; 68 rects[i].y = y; 69 rects[i].width = rects[i].height = size; 70 71 y += step; 72 rows++; 73 if (y + size > HEIGHT || rows == MAXROWS) { 74 rows = 0; 75 y = lw; 76 x += step; 77 if (x + size > WIDTH) { 78 x = lw; 79 } 80 } 81 } 82 83 SetFillStyle(xp, p); 84 85 return reps; 86} 87 88void 89DoRectangles(XParms xp, Parms p, int reps) 90{ 91 int i; 92 93 for (i = 0; i != reps; i++) { 94 XFillRectangles(xp->d, xp->w, pgc, rects, p->objects); 95 if (pgc == xp->bggc) 96 pgc = xp->fggc; 97 else 98 pgc = xp->bggc; 99 CheckAbort (); 100 } 101} 102 103void 104DoOutlineRectangles(XParms xp, Parms p, int reps) 105{ 106 int i; 107 108 for (i = 0; i != reps; i++) { 109 XDrawRectangles (xp->d, xp->w, pgc, rects, p->objects); 110 if (pgc == xp->bggc) 111 pgc = xp->fggc; 112 else 113 pgc = xp->bggc; 114 CheckAbort (); 115 } 116} 117 118void 119EndRectangles(XParms xp, Parms p) 120{ 121 free(rects); 122} 123 124