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_text.c,v
< prev
next >
Wrap
Text File
|
1989-12-07
|
12KB
|
573 lines
head 2.4;
access ;
symbols pre-merge:2.0;
locks ; strict;
comment @ * @;
2.4
date 89.12.07.16.36.20; author joel; state Exp;
branches ;
next 2.3;
2.3
date 89.05.11.16.44.52; author joel; state Exp;
branches ;
next 2.2;
2.2
date 89.05.08.18.38.53; author joel; state Exp;
branches ;
next 2.1;
2.1
date 89.05.03.14.18.04; author joel; state Exp;
branches ;
next 2.0;
2.0
date 89.01.31.17.06.59; author erik; state Exp;
branches ;
next 1.3;
1.3
date 89.01.31.17.06.59; author joel; state Exp;
branches ;
next 1.2;
1.2
date 88.12.15.13.40.31; author joel; state Exp;
branches ;
next 1.1;
1.1
date 88.06.17.12.41.13; author joel; state Exp;
branches ;
next ;
desc
@@
2.4
log
@Changed interface to p->reps.
@
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 char **charBuf;
static XFontStruct *font, *bfont;
static int height, ypos;
static XTextItem *items;
static int charsPerLine, totalLines;
#define XPOS 20
#define SEGS 3
int InitText(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i, j;
char ch;
XGCValues gcv;
font = XLoadQueryFont(xp->d, p->font);
if (font == NULL) {
printf("Could not load font '%s', benchmark omitted\n", p->font);
return 0;
}
bfont = NULL;
if (p->bfont != NULL) {
bfont = XLoadQueryFont(xp->d, p->bfont);
if (bfont == NULL) {
printf("Could not load font '%s', benchmark omitted\n", p->bfont);
return 0;
}
}
ypos = XPOS;
height = (font->max_bounds.ascent + font->max_bounds.descent) + 1;
if (bfont != NULL) {
int h = (bfont->max_bounds.ascent + bfont->max_bounds.descent) + 1;
if (h > height)
height = h;
}
gcv.font = font->fid;
XChangeGC(xp->d, xp->fggc, GCFont, &gcv);
XChangeGC(xp->d, xp->bggc, GCFont, &gcv);
charsPerLine = p->objects;
charsPerLine = (charsPerLine + 3) & ~3;
p->objects = charsPerLine;
totalLines = '\177' - ' ' + 1;
if (totalLines > reps) totalLines = reps;
charBuf = (char **) malloc(totalLines*sizeof (char *));
if (p->special)
items = (XTextItem *) malloc(totalLines*SEGS*sizeof (XTextItem));
for (i = 0; i != totalLines; i++) {
charBuf[i] = (char *) malloc (sizeof (char)*charsPerLine);
ch = i + ' ';
for (j = 0; j != charsPerLine; j++) {
charBuf[i][j] = ch;
if (ch == '\177') ch = ' '; else ch++;
}
if (p->special) {
items[i*SEGS+0].chars = &(charBuf[i][0]);
items[i*SEGS+0].nchars = charsPerLine/4;
items[i*SEGS+0].delta = 0;
items[i*SEGS+0].font = font->fid;
items[i*SEGS+1].chars = &(charBuf[i][charsPerLine/4]);
items[i*SEGS+1].nchars = charsPerLine/2;
items[i*SEGS+1].delta = 3;
items[i*SEGS+1].font = bfont->fid;
items[i*SEGS+2].chars = &(charBuf[i][3*charsPerLine/4]);
items[i*SEGS+2].nchars = charsPerLine/4;
items[i*SEGS+2].delta = 3;
items[i*SEGS+2].font = font->fid;
}
}
return reps;
}
void DoText(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i, line, startLine;
startLine = 0;
line = 0;
for (i = 0; i != reps; i++) {
XDrawString(
xp->d, xp->w, xp->fggc, XPOS, ypos, charBuf[line], charsPerLine);
ypos += height;
if (ypos > HEIGHT - height) {
/* Wraparound to top of window */
ypos = XPOS;
line = startLine;
startLine = (startLine + 1) % totalLines;
}
line = (line + 1) % totalLines;
}
}
void DoPolyText(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i, line, startLine;
startLine = 0;
line = 0;
for (i = 0; i != reps; i++) {
XDrawText(
xp->d, xp->w, xp->fggc, XPOS, ypos, &items[line*SEGS], SEGS);
ypos += height;
if (ypos > HEIGHT - height) {
/* Wraparound to top of window */
ypos = XPOS;
line = startLine;
startLine = (startLine + 1) % totalLines;
}
line = (line + 1) % totalLines;
}
}
void DoImageText(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i, line, startLine;
startLine = 0;
line = 0;
for (i = 0; i != reps; i++) {
XDrawImageString(
xp->d, xp->w, xp->fggc, XPOS, ypos, charBuf[line], charsPerLine);
ypos += height;
if (ypos > HEIGHT - height) {
/* Wraparound to top of window */
ypos = XPOS;
startLine = (startLine + 17) % totalLines;
line = startLine;
}
line = (line + 1) % totalLines;
}
}
void ClearTextWin(xp, p)
XParms xp;
Parms p;
{
XClearWindow(xp->d, xp->w);
}
void EndText(xp, p)
XParms xp;
Parms p;
{
int i;
for (i = 0; i != totalLines; i++)
free(charBuf[i]);
free(charBuf);
if (p->special)
free(items);
XFreeFont(xp->d, font);
if (bfont != NULL)
XFreeFont(xp->d, bfont);
}
@
2.3
log
@Parameters to all routines now (xp, p)
MAXROWS used in all routines
Junked most global communication variables
@
text
@d36 1
a36 1
Bool InitText(xp, p)
d39 1
d48 1
a48 1
return False;
d56 1
a56 1
return False;
d76 1
a76 1
if (totalLines > p->reps) totalLines = p->reps;
d104 1
a104 1
return True;
d107 1
a107 1
void DoText(xp, p)
d110 1
d116 1
a116 1
for (i = 0; i != p->reps; i++) {
d130 1
a130 1
void DoPolyText(xp, p)
d133 1
d139 1
a139 1
for (i = 0; i != p->reps; i++) {
d153 1
a153 1
void DoImageText(xp, p)
d156 1
d162 1
a162 1
for (i = 0; i != p->reps; i++) {
@
2.2
log
@No random numbers, made to fit 600x600 window, no clipped text at top of
screen.
@
text
@d1 23
a25 1
static Window w;
a26 1
static GC fggc, bggc;
d33 1
a33 1
#define SEGMENTS 3
d36 3
a38 3
Bool InitText(d, p)
Display *d;
Parms p;
d40 3
a42 3
int i, j;
char ch;
XGCValues gcv;
d44 1
a44 1
font = XLoadQueryFont (d, p->font);
d50 1
d52 1
a52 1
bfont = XLoadQueryFont (d, p->bfont);
a56 2
} else {
bfont = NULL;
d58 1
a65 1
CreatePerfStuff (d, 1, WIDTH, HEIGHT, &w, &bggc, &fggc);
d67 2
a68 2
XChangeGC (d, fggc, GCFont, &gcv);
XChangeGC (d, bggc, GCFont, &gcv);
d79 1
a79 1
items = (XTextItem *) malloc(totalLines*SEGMENTS*sizeof (XTextItem));
d81 1
a81 1
for (i = 0; i < totalLines; i++) {
d84 1
a84 1
for (j = 0; j < charsPerLine; j++) {
d89 12
a100 12
items[i*SEGMENTS+0].chars = &(charBuf[i][0]);
items[i*SEGMENTS+0].nchars = charsPerLine/4;
items[i*SEGMENTS+0].delta = 0;
items[i*SEGMENTS+0].font = font->fid;
items[i*SEGMENTS+1].chars = &(charBuf[i][charsPerLine/4]);
items[i*SEGMENTS+1].nchars = charsPerLine/2;
items[i*SEGMENTS+1].delta = 3;
items[i*SEGMENTS+1].font = bfont->fid;
items[i*SEGMENTS+2].chars = &(charBuf[i][3*charsPerLine/4]);
items[i*SEGMENTS+2].nchars = charsPerLine/4;
items[i*SEGMENTS+2].delta = 3;
items[i*SEGMENTS+2].font = font->fid;
d106 3
a108 3
void DoText(d, p)
Display *d;
Parms p;
d114 3
a116 2
for (i = 0; i < p->reps; i++) {
XDrawString(d, w, fggc, XPOS, ypos, charBuf[line], charsPerLine);
d128 3
a130 3
void DoPolyText(d, p)
Display *d;
Parms p;
d136 3
a138 2
for (i = 0; i < p->reps; i++) {
XDrawText(d, w, fggc, XPOS, ypos, &items[line*SEGMENTS], SEGMENTS);
d150 3
a152 3
void DoImageText(d, p)
Display *d;
Parms p;
d158 1
a158 1
for (i = 0; i < p->reps; i++) {
d160 1
a160 1
d, w, fggc, XPOS, ypos, charBuf[line], charsPerLine);
d172 3
a174 1
void ClearTextWin(d, numLines)
d176 1
a176 1
XClearWindow(d, w);
d179 3
a181 3
void EndText(d, p)
Display *d;
Parms p;
d185 1
a185 4
XDestroyWindow(d, w);
XFreeGC(d, fggc);
XFreeGC(d, bggc);
for (i = 0; i < totalLines; i++)
d190 1
a190 1
XFreeFont(d, font);
d192 1
a192 1
XFreeFont(d, bfont);
@
2.1
log
@Massive changes, I'm not going to go into details.
@
text
@d4 1
a4 1
static char **charBuf = NULL;
d9 1
a12 2
#define STARTBOLD 20
#define NUMBOLD 20
d14 1
d20 1
d45 1
a45 1
CreatePerfStuff (d, 1, 800, HEIGHT, &w, &bggc, &fggc);
d50 17
a66 25
if (charBuf == NULL) {
charBuf = (char **) malloc(p->reps*sizeof (char *));
if (p->special)
items = (XTextItem *) malloc(p->reps*SEGMENTS*sizeof (XTextItem));
else
items = NULL;
for (i = 0; i < p->reps; i++) {
charBuf[i] = (char *) malloc (sizeof (char)*CHARS);
for (j = 0; j < CHARS; j++) {
charBuf[i][j] = ' ' + (rand () % ('\177' - ' '));
if (p->special) {
items[i*SEGMENTS+0].chars = &(charBuf[i][0]);
items[i*SEGMENTS+0].nchars = STARTBOLD;
items[i*SEGMENTS+0].delta = 0;
items[i*SEGMENTS+0].font = font->fid;
items[i*SEGMENTS+1].chars = &(charBuf[i][STARTBOLD]);
items[i*SEGMENTS+1].nchars = NUMBOLD;
items[i*SEGMENTS+1].delta = 3;
items[i*SEGMENTS+1].font = bfont->fid;
items[i*SEGMENTS+2].chars = &(charBuf[i][STARTBOLD + NUMBOLD]);
items[i*SEGMENTS+2].nchars = CHARS - (STARTBOLD + NUMBOLD);
items[i*SEGMENTS+2].delta = 3;
items[i*SEGMENTS+2].font = font->fid;
}
}
d68 14
d90 1
a90 1
int i;
d92 2
d95 9
a103 2
XDrawString(d, w, fggc, XPOS, ypos, charBuf[i], CHARS);
ypos = (ypos + height) % (HEIGHT - height);
d111 1
a111 1
int i;
d113 2
d116 9
a124 2
XDrawText(d, w, fggc, XPOS, ypos, &items[i*SEGMENTS], SEGMENTS);
ypos = (ypos + height) % (HEIGHT - height);
d132 1
a132 1
int i;
d134 2
d138 9
a146 2
d, w, (i & 1) ? fggc : bggc, XPOS, ypos, charBuf[i], CHARS);
ypos = (ypos + height) % (HEIGHT - height);
d164 1
a164 1
for (i = 0; i < p->reps; i++)
d167 1
a167 1
if (items != NULL)
a168 1
charBuf = NULL;
@
2.0
log
@version from /usr/src/pmax
@
text
@d15 1
a15 1
void InitText(d, p)
d23 6
a28 1
if (p->bfont != NULL)
d30 5
a34 1
else
d36 1
d76 1
@
1.3
log
@Added -fg -bg capabilities
@
text
@@
1.2
log
@Made charBuf static so as not to interfere with other modules,
like do_plane.c
@
text
@d5 1
a5 1
static GC blackgc, whitegc;
d34 1
a34 1
CreatePerfStuff (d, 1, 800, HEIGHT, &w, &whitegc, &blackgc);
d36 2
a37 2
XChangeGC (d, blackgc, GCFont, &gcv);
XChangeGC (d, whitegc, GCFont, &gcv);
d75 1
a75 1
XDrawString(d, w, blackgc, XPOS, ypos, charBuf[i], CHARS);
d87 1
a87 1
XDrawText(d, w, blackgc, XPOS, ypos, &items[i*SEGMENTS], SEGMENTS);
d100 1
a100 1
d, w, (i & 1) ? blackgc : whitegc, XPOS, ypos, charBuf[i], CHARS);
d117 2
a118 2
XFreeGC(d, blackgc);
XFreeGC(d, whitegc);
@
1.1
log
@Initial revision
@
text
@d4 1
a4 1
char **charBuf = NULL;
@