do_rects.c revision 533545b5
1264fa531Smrg/***************************************************************************** 2264fa531SmrgCopyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts. 3264fa531Smrg 4264fa531Smrg All Rights Reserved 5264fa531Smrg 6264fa531SmrgPermission to use, copy, modify, and distribute this software and its 7264fa531Smrgdocumentation for any purpose and without fee is hereby granted, 8264fa531Smrgprovided that the above copyright notice appear in all copies and that 9264fa531Smrgboth 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 12264fa531Smrgsoftware 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 30264fa531Smrgint 31533545b5SmrgInitRectangles(XParms xp, Parms p, int64_t reps) 32264fa531Smrg{ 33264fa531Smrg int i; 34264fa531Smrg int size = p->special; 35264fa531Smrg int step; 36264fa531Smrg int x, y; 37264fa531Smrg int rows; 38264fa531Smrg int lw = 0; 39264fa531Smrg 40264fa531Smrg pgc = xp->fggc; 41264fa531Smrg 42264fa531Smrg if (p->bfont) 43264fa531Smrg { 44264fa531Smrg lw = atoi (p->bfont); 45264fa531Smrg 46264fa531Smrg XSetLineAttributes(xp->d, xp->bggc, lw, LineSolid, CapButt, JoinMiter); 47264fa531Smrg XSetLineAttributes(xp->d, xp->fggc, lw, LineSolid, CapButt, JoinMiter); 48264fa531Smrg lw = (lw >> 1) + 1; 49264fa531Smrg } 50264fa531Smrg 51264fa531Smrg rects = (XRectangle *)malloc(p->objects * sizeof(XRectangle)); 52264fa531Smrg x = lw; 53264fa531Smrg y = lw; 54264fa531Smrg rows = 0; 55264fa531Smrg if (xp->pack) { 56264fa531Smrg /* Pack rectangles as close as possible, mainly for debugging faster 57264fa531Smrg tiling, stippling routines in a server */ 58264fa531Smrg step = size; 59264fa531Smrg } else { 60264fa531Smrg /* Try to exercise all alignments...any odd number is okay */ 61264fa531Smrg step = size + 1 + (size % 2); 62264fa531Smrg } 63264fa531Smrg 64264fa531Smrg for (i = 0; i != p->objects; i++) { 65264fa531Smrg rects[i].x = x; 66264fa531Smrg rects[i].y = y; 67264fa531Smrg rects[i].width = rects[i].height = size; 68264fa531Smrg 69264fa531Smrg y += step; 70264fa531Smrg rows++; 71264fa531Smrg if (y + size > HEIGHT || rows == MAXROWS) { 72264fa531Smrg rows = 0; 73264fa531Smrg y = lw; 74264fa531Smrg x += step; 75264fa531Smrg if (x + size > WIDTH) { 76264fa531Smrg x = lw; 77264fa531Smrg } 78264fa531Smrg } 79264fa531Smrg } 80264fa531Smrg 81264fa531Smrg SetFillStyle(xp, p); 82264fa531Smrg 83264fa531Smrg return reps; 84264fa531Smrg} 85264fa531Smrg 86264fa531Smrgvoid 87533545b5SmrgDoRectangles(XParms xp, Parms p, int64_t reps) 88264fa531Smrg{ 89264fa531Smrg int i; 90264fa531Smrg 91264fa531Smrg for (i = 0; i != reps; i++) { 92264fa531Smrg XFillRectangles(xp->d, xp->w, pgc, rects, p->objects); 93264fa531Smrg if (pgc == xp->bggc) 94264fa531Smrg pgc = xp->fggc; 95264fa531Smrg else 96264fa531Smrg pgc = xp->bggc; 97264fa531Smrg CheckAbort (); 98264fa531Smrg } 99264fa531Smrg} 100264fa531Smrg 101264fa531Smrgvoid 102533545b5SmrgDoOutlineRectangles(XParms xp, Parms p, int64_t reps) 103264fa531Smrg{ 104264fa531Smrg int i; 105264fa531Smrg 106264fa531Smrg for (i = 0; i != reps; i++) { 107264fa531Smrg XDrawRectangles (xp->d, xp->w, pgc, rects, p->objects); 108264fa531Smrg if (pgc == xp->bggc) 109264fa531Smrg pgc = xp->fggc; 110264fa531Smrg else 111264fa531Smrg pgc = xp->bggc; 112264fa531Smrg CheckAbort (); 113264fa531Smrg } 114264fa531Smrg} 115264fa531Smrg 116264fa531Smrgvoid 117264fa531SmrgEndRectangles(XParms xp, Parms p) 118264fa531Smrg{ 119264fa531Smrg free(rects); 120264fa531Smrg} 121264fa531Smrg 122