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