1264fa531Smrg/***************************************************************************** 2264fa531SmrgCopyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts. 3264fa531Smrg 4264fa531Smrg All Rights Reserved 5264fa531Smrg 6dfac8f13SmrgPermission to use, copy, modify, and distribute this software and its 7dfac8f13Smrgdocumentation for any purpose and without fee is hereby granted, 8264fa531Smrgprovided that the above copyright notice appear in all copies and that 9dfac8f13Smrgboth that copyright notice and this permission notice appear in 10264fa531Smrgsupporting documentation, and that the name of Digital not be 11264fa531Smrgused in advertising or publicity pertaining to distribution of the 12dfac8f13Smrgsoftware without specific, written prior permission. 13264fa531Smrg 14264fa531SmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 15264fa531SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 16264fa531SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 17264fa531SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 18264fa531SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 19264fa531SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 20264fa531SmrgSOFTWARE. 21264fa531Smrg 22264fa531Smrg******************************************************************************/ 23264fa531Smrg 24264fa531Smrg#include "x11perf.h" 25264fa531Smrg#include "bitmaps.h" 26264fa531Smrg 27264fa531Smrgstatic XRectangle *rects; 28264fa531Smrgstatic GC pgc; 29264fa531Smrg 30dfac8f13Smrgint 31533545b5SmrgInitRectangles(XParms xp, Parms p, int64_t reps) 32264fa531Smrg{ 33264fa531Smrg int size = p->special; 34264fa531Smrg int step; 35264fa531Smrg int x, y; 36264fa531Smrg int rows; 37264fa531Smrg int lw = 0; 38264fa531Smrg 39264fa531Smrg pgc = xp->fggc; 40264fa531Smrg 41264fa531Smrg if (p->bfont) 42264fa531Smrg { 43264fa531Smrg lw = atoi (p->bfont); 44264fa531Smrg 45264fa531Smrg XSetLineAttributes(xp->d, xp->bggc, lw, LineSolid, CapButt, JoinMiter); 46264fa531Smrg XSetLineAttributes(xp->d, xp->fggc, lw, LineSolid, CapButt, JoinMiter); 47264fa531Smrg lw = (lw >> 1) + 1; 48264fa531Smrg } 49264fa531Smrg 50c9e4df9bSmrg rects = malloc(p->objects * sizeof(XRectangle)); 51264fa531Smrg x = lw; 52264fa531Smrg y = lw; 53264fa531Smrg rows = 0; 54264fa531Smrg if (xp->pack) { 55264fa531Smrg /* Pack rectangles as close as possible, mainly for debugging faster 56264fa531Smrg tiling, stippling routines in a server */ 57264fa531Smrg step = size; 58264fa531Smrg } else { 59264fa531Smrg /* Try to exercise all alignments...any odd number is okay */ 60264fa531Smrg step = size + 1 + (size % 2); 61264fa531Smrg } 62264fa531Smrg 63c9e4df9bSmrg for (int i = 0; i != p->objects; i++) { 64264fa531Smrg rects[i].x = x; 65264fa531Smrg rects[i].y = y; 66264fa531Smrg rects[i].width = rects[i].height = size; 67264fa531Smrg 68264fa531Smrg y += step; 69264fa531Smrg rows++; 70264fa531Smrg if (y + size > HEIGHT || rows == MAXROWS) { 71264fa531Smrg rows = 0; 72264fa531Smrg y = lw; 73264fa531Smrg x += step; 74264fa531Smrg if (x + size > WIDTH) { 75264fa531Smrg x = lw; 76264fa531Smrg } 77264fa531Smrg } 78264fa531Smrg } 79264fa531Smrg 80264fa531Smrg SetFillStyle(xp, p); 81264fa531Smrg 82264fa531Smrg return reps; 83264fa531Smrg} 84264fa531Smrg 85dfac8f13Smrgvoid 86533545b5SmrgDoRectangles(XParms xp, Parms p, int64_t reps) 87264fa531Smrg{ 88c9e4df9bSmrg for (int i = 0; i != reps; i++) { 89264fa531Smrg XFillRectangles(xp->d, xp->w, pgc, rects, p->objects); 90264fa531Smrg if (pgc == xp->bggc) 91264fa531Smrg pgc = xp->fggc; 92264fa531Smrg else 93264fa531Smrg pgc = xp->bggc; 94264fa531Smrg CheckAbort (); 95264fa531Smrg } 96264fa531Smrg} 97264fa531Smrg 98dfac8f13Smrgvoid 99533545b5SmrgDoOutlineRectangles(XParms xp, Parms p, int64_t reps) 100264fa531Smrg{ 101c9e4df9bSmrg for (int i = 0; i != reps; i++) { 102264fa531Smrg XDrawRectangles (xp->d, xp->w, pgc, rects, p->objects); 103264fa531Smrg if (pgc == xp->bggc) 104264fa531Smrg pgc = xp->fggc; 105264fa531Smrg else 106264fa531Smrg pgc = xp->bggc; 107264fa531Smrg CheckAbort (); 108264fa531Smrg } 109264fa531Smrg} 110264fa531Smrg 111dfac8f13Smrgvoid 112264fa531SmrgEndRectangles(XParms xp, Parms p) 113264fa531Smrg{ 114264fa531Smrg free(rects); 115264fa531Smrg} 116264fa531Smrg 117