home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
x
/
x11p-13.zip
/
RCS
/
do_segs.c,v
< prev
next >
Wrap
Text File
|
1989-12-13
|
14KB
|
757 lines
head 2.10;
access ;
symbols pre-merge:2.0;
locks ; strict;
comment @ * @;
2.10
date 89.12.13.19.09.07; author joel; state Exp;
branches ;
next 2.9;
2.9
date 89.12.13.11.03.55; author joel; state Exp;
branches ;
next 2.8;
2.8
date 89.12.07.16.34.50; author joel; state Exp;
branches ;
next 2.7;
2.7
date 89.11.20.13.26.47; author joel; state Exp;
branches ;
next 2.6;
2.6
date 89.10.23.18.11.25; author joel; state Exp;
branches ;
next 2.5;
2.5
date 89.06.23.14.13.48; author joel; state Exp;
branches ;
next 2.4;
2.4
date 89.05.11.16.44.43; author joel; state Exp;
branches ;
next 2.3;
2.3
date 89.05.03.14.17.58; author joel; state Exp;
branches ;
next 2.2;
2.2
date 89.04.20.11.54.43; author joel; state Exp;
branches ;
next 2.1;
2.1
date 89.04.18.14.13.55; author joel; state Exp;
branches ;
next 2.0;
2.0
date 89.02.28.19.19.39; author erik; state Exp;
branches ;
next 1.1;
1.1
date 89.02.28.19.19.39; author joel; state Exp;
branches ;
next ;
desc
@Segments code, for unconnected line benchmarking
@
2.10
log
@Make sure that all angles of compass treated equally.
Generate slightly different patter...more boring for 100 pixels, more
interesting for 10 and 500.
@
text
@/*****************************************************************************
Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************************/
#include "x11perf.h"
static XSegment *segments;
static GC pgc;
int InitSegments(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int size;
int half;
int i;
int rows; /* Number of rows filled in current column */
int x, y; /* base of square to draw in */
int x1, y1, x2, y2; /* offsets into square */
int phase; /* how far into 0..8*size we are */
int phaseinc; /* how much to increment phase at each segment */
int size8; /* 8 * size */
XGCValues gcv;
pgc = xp->fggc;
size = p->special;
size8 = 8 * size;
half = (size + 19) / 20;
segments = (XSegment *)malloc((p->objects) * sizeof(XSegment));
/* All this x, x1, etc. stuff is to create a pattern that
(1) scans down the screen vertically, with each new segment going
into a square of size^2.
(2) rotates the endpoints clockwise around the square
(3) rotates by ``large'' steps if we aren't going to paint enough
segments to get full coverage
(4) uses CapNotLast so we can create segments of length 1 that
nonetheless have a distinct direction
*/
x = half; y = half;
phase = 0;
phaseinc = size8 / p->objects;
if (phaseinc == 0) phaseinc = 1;
rows = 0;
for (i = 0; i != p->objects; i++) {
switch (phase / size) {
case 0:
x1 = 0;
y1 = 0;
x2 = size;
y2 = phase;
break;
case 1:
x1 = phase % size;
y1 = 0;
x2 = size;
y2 = size;
break;
case 2:
x1 = size;
y1 = 0;
x2 = size - phase % size;
y2 = size;
break;
case 3:
x1 = size;
y1 = phase % size;
x2 = 0;
y2 = size;
break;
case 4:
x1 = size;
y1 = size;
x2 = 0;
y2 = size - phase % size;
break;
case 5:
x1 = size - phase % size;
y1 = size;
x2 = 0;
y2 = 0;
break;
case 6:
x1 = 0;
y1 = size;
x2 = phase % size;
y2 = 0;
break;
case 7:
x1 = 0;
y1 = size - phase % size;
x2 = size;
y2 = 0;
break;
} /* end switch */
segments[i].x1 = x + x1;
segments[i].y1 = y + y1;
segments[i].x2 = x + x2;
segments[i].y2 = y + y2;
/* Change square to draw segment in */
rows++;
y += size;
if (y >= HEIGHT - size - half || rows == MAXROWS) {
/* Go to next column */
rows = 0;
y = half;
x += size;
if (x >= WIDTH - size - half) {
x = half;
}
}
/* Increment phase */
phase += phaseinc;
if (phase >= size8) phase -= size8;
}
gcv.cap_style = CapNotLast;
XChangeGC(xp->d, xp->fggc, GCCapStyle, &gcv);
XChangeGC(xp->d, xp->bggc, GCCapStyle, &gcv);
return reps;
}
int InitDashedSegments(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
char dashes[2];
(void)InitSegments(xp, p, reps);
/* Modify GCs to draw dashed */
XSetLineAttributes
(xp->d, xp->bggc, 0, LineOnOffDash, CapNotLast, JoinMiter);
XSetLineAttributes
(xp->d, xp->fggc, 0, LineOnOffDash, CapNotLast, JoinMiter);
dashes[0] = 3; dashes[1] = 2;
XSetDashes(xp->d, xp->fggc, 0, dashes, 2);
XSetDashes(xp->d, xp->bggc, 0, dashes, 2);
return reps;
}
int InitDoubleDashedSegments(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
char dashes[2];
(void)InitSegments(xp, p, reps);
/* Modify GCs to draw dashed */
XSetLineAttributes
(xp->d, xp->bggc, 0, LineDoubleDash, CapNotLast, JoinMiter);
XSetLineAttributes
(xp->d, xp->fggc, 0, LineDoubleDash, CapNotLast, JoinMiter);
dashes[0] = 3; dashes[1] = 2;
XSetDashes(xp->d, xp->fggc, 0, dashes, 2);
XSetDashes(xp->d, xp->bggc, 0, dashes, 2);
return reps;
}
void DoSegments(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i;
for (i = 0; i != reps; i++) {
XDrawSegments(xp->d, xp->w, pgc, segments, p->objects);
if (pgc == xp->bggc)
pgc = xp->fggc;
else
pgc = xp->bggc;
}
}
void EndSegments(xp, p)
XParms xp;
Parms p;
{
free(segments);
}
@
2.9
log
@Use CapNotLast, don't reduce size, so that 1-pixel segs have a definite
direction.
@
text
@a24 1
#include "stdio.h"
d39 4
a42 4
int x1, y1; /* offsets into square */
int x1inc, y1inc; /* How to get to next x1, y1 */
int minorphase; /* # iterations left with current x1inc, y1inc */
int majorphase; /* count 0..3 for which type of x1inc, y1inc */
d48 1
d53 1
a53 1
/* All this x, x1, x1inc, etc. stuff is to create a pattern that
d55 1
a55 1
into a square of size x size.
d59 5
a63 2
(3) CapNotLast used so we can create segments of length 1 that
nonetheless have a distince direction
d67 3
a69 5
x1 = 0; y1 = 0;
x1inc = 1; y1inc = 0;
minorphase = size;
majorphase = 0;
d73 58
d133 2
a134 2
segments[i].x2 = x + size - x1;
segments[i].y2 = y + size - y1;
a135 6
/*
if (i < 20) {
printf("%d %d %d %d\n", segments[i].x1, segments[i].y1,
segments[i].x2, segments[i].y2);
}
*/
d138 1
a138 1
y += size + 1;
d143 1
a143 1
x += size + 1;
d149 3
a151 3
/* Change coordinates of offsets in square */
x1 += x1inc;
y1 += y1inc;
a152 12
/* Change increments if needed */
minorphase--;
if (minorphase <= 0) {
minorphase = size;
majorphase = (majorphase + 1) % 4;
switch (majorphase) {
case 0: x1inc = 1; y1inc = 0; break;
case 1: x1inc = 0; y1inc = 1; break;
case 2: x1inc = -1; y1inc = 0; break;
case 3: x1inc = 0; y1inc = -1; break;
}
}
@
2.8
log
@Changed interface to p->reps
@
text
@d25 1
d44 1
a52 2
size--; /* Because endcap counts as 1 pixel */
d59 2
d77 6
d113 5
d132 4
a135 2
XSetLineAttributes(xp->d, xp->bggc, 0, LineOnOffDash, CapButt, JoinMiter);
XSetLineAttributes(xp->d, xp->fggc, 0, LineOnOffDash, CapButt, JoinMiter);
d152 4
a155 2
XSetLineAttributes(xp->d, xp->bggc, 0, LineDoubleDash, CapButt, JoinMiter);
XSetLineAttributes(xp->d, xp->fggc, 0, LineDoubleDash, CapButt, JoinMiter);
@
2.7
log
@done
done
Declare pgc as static, so switch between fggc and bggc happens every time,
not just within one iteration of tests. (Helps make things look better on
slow machines, which may only run 1 iteration.)
@
text
@d29 1
a29 1
Bool InitSegs(xp, p)
d32 1
d105 1
a105 1
return True;
d109 1
a109 1
Bool InitDashedSegs(xp, p)
d112 1
d116 1
a116 1
(void)InitSegs(xp, p);
d124 1
a124 1
return True;
d127 1
a127 1
Bool InitDoubleDashedSegs(xp, p)
d130 1
d134 1
a134 1
(void)InitSegs(xp, p);
d142 1
a142 1
return True;
d145 1
a145 1
void DoSegs(xp, p)
d148 1
d152 1
a152 1
for (i = 0; i != p->reps; i++) {
d161 1
a161 1
void EndSegs(xp, p)
@
2.6
log
@Make sure that wide lines aren't clipped.
@
text
@d27 1
d43 2
a145 1
GC pgc;
a147 1
pgc = xp->fggc;
@
2.5
log
@Added double-dashed segments
@
text
@d33 1
d43 1
d57 3
a59 3
x = 0; y = 0;
x1 = 0; y1 = 0;
x1inc = 1; y1inc = 0;
d74 1
a74 1
if (y >= HEIGHT - size || rows == MAXROWS) {
d77 1
a77 1
y = 0;
d79 2
a80 2
if (x >= WIDTH - size) {
x = 0;
@
2.4
log
@Parameters to all routines now (xp, p)
MAXROWS used in all routines
Junked most global communication variables
@
text
@d120 17
@
2.3
log
@Massive changes, I'm not going to go into details.
@
text
@d1 23
a25 1
static Window w;
a26 1
static GC bggc, fggc;
d28 2
a29 2
Bool InitSegs(d, p)
Display *d;
d32 1
a32 1
int size;
d34 1
d61 3
a63 1
for (i = 0; i < (p->objects); i++) {
d70 1
d72 1
a72 1
if (y >= HEIGHT - size) {
d74 1
a98 1
CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, &bggc, &fggc);
d103 2
a104 2
Bool InitDashedSegs(d, p)
Display *d;
d109 1
a109 1
(void)InitSegs(d, p);
d112 5
a116 5
XSetLineAttributes(d, bggc, 0, LineOnOffDash, CapButt, JoinMiter);
XSetLineAttributes(d, fggc, 0, LineOnOffDash, CapButt, JoinMiter);
dashes[0] = 1; dashes[1] = 3;
XSetDashes(d, fggc, 0, dashes, 2);
XSetDashes(d, bggc, 0, dashes, 2);
d120 3
a122 3
void DoSegs(d, p)
Display *d;
Parms p;
d127 5
a131 6
pgc = bggc;
for (i=0; i<p->reps; i++)
{
XDrawSegments(d, w, pgc, segments, p->objects);
if (pgc == bggc)
pgc = fggc;
d133 1
a133 1
pgc = bggc;
d137 2
a138 2
void EndSegs(d, p)
Display *d;
a140 3
XDestroyWindow(d, w);
XFreeGC(d, bggc);
XFreeGC(d, fggc);
@
2.2
log
@Changed overlapping windows to screw clipping up more
@
text
@d3 1
a5 6
static Window w[4];
static XRectangle ws[3] = {
{150, 150, 90, 90},
{300, 180, 90, 90},
{450, 210, 90, 90}
};
d7 1
a7 1
void InitSizedSegs(d, p, size)
d10 1
a11 1
{
d19 2
a20 3
for (i = 0; i < 4; i++)
w[i] = None;
i = 0;
d73 2
a74 5
CreatePerfStuff(d, 1, WIDTH, HEIGHT, w, &bggc, &fggc);
for (i = 0; i < p->special; i++)
w[i+1] = CreatePerfWindow(
d, ws[i].x, ws[i].y, ws[i].width, ws[i].height);
a76 6
void InitSegs1(d, p)
Display *d;
Parms p;
{
InitSizedSegs(d, p, 1);
}
d78 1
a78 2
void InitSegs10(d, p)
d80 1
a80 1
Parms p;
d82 1
a82 2
InitSizedSegs(d, p, 10);
}
d84 1
d86 7
a92 5
void InitSegs100(d, p)
Display *d;
Parms p;
{
InitSizedSegs(d, p, 100);
a94 9
void InitSegs500(d, p)
Display *d;
Parms p;
{
InitSizedSegs(d, p, 500);
}
d105 1
a105 1
XDrawSegments(d, w[0], pgc, segments, p->objects);
d117 1
a117 4
int i;
for (i = 0; i < 4; i++)
if (w[i] != None)
XDestroyWindow(d, w[i]);
@
2.1
log
@Non-random segment painting, in columns down screen to make TLB faulting
as bad as possible, and in all possible orientations of a line of the
given length.
@
text
@d7 3
a9 3
{100, 100, 200, 200},
{150, 150, 200, 200},
{200, 200, 200, 200}
d86 1
a86 1
void InitSmallSegs(d, p)
d94 1
a94 1
void InitMedSegs(d, p)
d102 1
a102 1
void InitSegs(d, p)
d106 8
d116 1
@
2.0
log
@version from /usr/src/pmax
@
text
@a2 4
/* define CONTINUOUS if you want each line segment to join with the previous */
#define CONTINUOUS
d17 6
a22 2
int i, incr;
int prevx, prevy;
a26 2
prevx = WIDTH / 2;
prevy = HEIGHT / 2;
d28 32
a59 13
for (i = 0; i < (p->objects); i++)
{
#ifdef CONTINUOUS
segments[i].x1 = prevx;
segments[i].y1 = prevy;
#else
segments[i].x1 = rand() % WIDTH;
segments[i].y1 = rand() % HEIGHT;
#endif
if (segments[i].x1 < size || ((rand() >> 12) & 1)) {
segments[i].x2 = segments[i].x1 + size;
} else {
segments[i].x2 = segments[i].x1 - size;
d61 16
a76 4
if (segments[i].y1 < size || ((rand() >> 12) & 1)) {
segments[i].y2 = segments[i].y1 + size;
} else {
segments[i].y2 = segments[i].y1 - size;
a77 4
#ifdef CONTINUOUS
prevx = segments[i].x2;
prevy = segments[i].y2;
#endif
d106 1
a106 26
int i;
int prevx, prevy;
for (i = 0; i < 4; i++)
w[i] = None;
i = 0;
segments = (XSegment *)malloc((p->objects) * sizeof(XSegment));
prevx = rand() % WIDTH;
prevy = rand() % HEIGHT;
for (i = 0; i < (p->objects); i++)
{
#ifdef CONTINUOUS
segments[i].x1 = prevx;
segments[i].y1 = prevy;
#else
segments[i].x1 = rand() % WIDTH;
segments[i].y1 = rand() % HEIGHT;
#endif
segments[i].x2 = prevx = rand() % WIDTH;
segments[i].y2 = prevy = rand() % HEIGHT;
}
CreatePerfStuff(d, 1, WIDTH, HEIGHT, w, &bggc, &fggc);
for (i = 0; i < p->special; i++)
w[i+1] = CreatePerfWindow(
d, ws[i].x, ws[i].y, ws[i].width, ws[i].height);
@
1.1
log
@Initial revision
@
text
@@