[Xprint] x11perf support for printer devices
Julien Lafon
julien.lafon at gmail.com
Sat Apr 23 06:22:31 EDT 2005
Hello,
I have spend some time to evaluate print job generation performance
and added support for printer devices to x11perf. It would be nice if
Roland or AlanC could comment on the patch here before I attach it to
a bugzilla rfe.
Julien
--
Julien Lafon
Senior Staff Engineer, Hitachi
-------------- next part --------------
Index: Imakefile
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/Imakefile,v
retrieving revision 1.4
diff -u -r1.4 Imakefile
--- Imakefile 11 Aug 2004 08:05:31 -0000 1.4
+++ Imakefile 22 Apr 2005 21:40:21 -0000
@@ -12,19 +12,24 @@
#if HasShm
SHMDEFS = -DMITSHM
#endif
-#if BuildRenderLibrary
+#if xBuildRenderLibrary
XRENDERDEFS = -DXRENDER
XRENDERDEPS = $(DEPXRENDERLIB)
XRENDERLIBS = $(XRENDERLIB)
XRENDERINCS = $(XRENDERINCLUDES)
#endif
-#if BuildXftLibrary
+#if xBuildXftLibrary
XFTDEFS = -DXFT -DXFREE86_FT2
XFTDEPS = XftClientDepLibs
XFTLIBS = XftClientLibs
XFTINCS = $(XFTINCLUDES) -I$(XBUILDINCDIR)
#endif
- DEFINES = $(SIGNAL_DEFINES) $(SHMDEFS) $(XFTDEFS) $(XRENDERDEFS)
+#if BuildXprintLib && BuildXprintClients
+ XPRINTLIBS = -lXprintUtil $(XPLIB)
+ XPRINTDEFS = -DXPRINT
+#endif
+
+ DEFINES = $(SIGNAL_DEFINES) $(SHMDEFS) $(XFTDEFS) $(XRENDERDEFS) $(XPRINTDEFS)
INCLUDES = $(TOP_INCLUDES) $(XFTINCS) $(XRENDERINCS)
PERFLIB = X11perfcompLib
HEADERS = x11perf.h bitmaps.h
@@ -40,7 +45,7 @@
do_dots.o do_windows.o do_movewin.o do_text.o \
do_blt.o do_arcs.o \
do_tris.o do_complex.o do_traps.o
-LOCAL_LIBRARIES = $(XFTLIBS) $(XRENDERLIBS) $(XMUULIB) $(XLIB)
+LOCAL_LIBRARIES = $(XFTLIBS) $(XRENDERLIBS) $(XPRINTLIBS) $(XMUULIB) $(XLIB)
DEPLIBS = $(XFTDEPS) $(XRENDERDEPS) $(DEPXMUULIB) $(DEPXLIB)
SYS_LIBRARIES = MathLibrary
Index: do_arcs.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/do_arcs.c,v
retrieving revision 1.2
diff -u -r1.2 do_arcs.c
--- do_arcs.c 23 Apr 2004 19:54:38 -0000 1.2
+++ do_arcs.c 22 Apr 2005 21:40:22 -0000
@@ -71,16 +71,16 @@
y += size + 1;
rows++;
- if (y >= HEIGHT - size - half || rows == MAXROWS) {
+ if (y >= xp->test_height - size - half || rows == MAXROWS) {
/* Go to next column */
rows = 0;
x += size + 1;
- if (x >= WIDTH - size) {
+ if (x >= xp->test_width - size) {
yorg++;
- if (yorg >= size + half || yorg >= HEIGHT - size - half) {
+ if (yorg >= size + half || yorg >= xp->test_height - size - half) {
yorg = half;
xorg++;
- if (xorg >= size + half || xorg >= WIDTH - size - half) {
+ if (xorg >= size + half || xorg >= xp->test_width - size - half) {
xorg = half;
}
}
@@ -289,12 +289,12 @@
y += size + 1;
rows++;
- if (y >= HEIGHT - size - half || rows == MAXROWS) {
+ if (y >= xp->test_height - size - half || rows == MAXROWS) {
/* Go to next column */
rows = 0;
y = half;
x += size + 1;
- if (x >= WIDTH - size - half) {
+ if (x >= xp->test_width - size - half) {
x = half;
}
}
Index: do_blt.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/do_blt.c,v
retrieving revision 1.2
diff -u -r1.2 do_blt.c
--- do_blt.c 23 Apr 2004 19:54:38 -0000 1.2
+++ do_blt.c 22 Apr 2005 21:40:23 -0000
@@ -36,29 +36,29 @@
#define NegMod(x, y) ((y) - (((-x)-1) % (7)) - 1)
static void
-InitBltLines(void)
+InitBltLines(XParms xp)
{
int i, x, y;
points[0].x = points[0].y = y = 0;
for (i = 1; i != NUMPOINTS/2; i++) {
if (i & 1) {
- points[i].x = WIDTH-1;
+ points[i].x = xp->test_width-1;
} else {
points[i].x = 0;
}
- y += HEIGHT / (NUMPOINTS/2);
+ y += xp->test_height / (NUMPOINTS/2);
points[i].y = y;
}
x = 0;
for (i = NUMPOINTS/2; i!= NUMPOINTS; i++) {
if (i & 1) {
- points[i].y = HEIGHT-1;
+ points[i].y = xp->test_height-1;
} else {
points[i].y = 0;
}
- x += WIDTH / (NUMPOINTS/2);
+ x += xp->test_width / (NUMPOINTS/2);
points[i].x = x;
}
}
@@ -66,7 +66,7 @@
int
InitScroll(XParms xp, Parms p, int reps)
{
- InitBltLines();
+ InitBltLines(xp);
XDrawLines(xp->d, xp->w, xp->fggc, points, NUMPOINTS, CoordModeOrigin);
return reps;
}
@@ -93,18 +93,18 @@
XCopyArea(xp->d, xp->w, xp->w, xp->fggc, x, y + delta,
size, size, x, y);
y += size;
- if (y + size + delta > HEIGHT) {
+ if (y + size + delta > xp->test_height) {
yorg += delta;
- if (yorg >= size || yorg + size + delta > HEIGHT) {
+ if (yorg >= size || yorg + size + delta > xp->test_height) {
yorg = 0;
xorg++;
- if (xorg >= size || xorg + size > WIDTH) {
+ if (xorg >= size || xorg + size > xp->test_width) {
xorg = 0;
}
}
y = yorg;
x += size;
- if (x + size > WIDTH) {
+ if (x + size > xp->test_width) {
x = xorg;
}
}
@@ -140,8 +140,8 @@
xinc = (size & ~3) + 1;
yinc = xinc + 3;
- width = (WIDTH - size) & ~31;
- height = (HEIGHT - size) & ~31;
+ width = (xp->test_width - size) & ~31;
+ height = (xp->test_height - size) & ~31;
x1 = 0;
y1 = 0;
@@ -199,10 +199,10 @@
(void) InitCopyWin(xp, p, reps);
/* Create pixmap to write stuff into, and initialize it */
- pix = XCreatePixmap(xp->d, xp->w, WIDTH, HEIGHT, xp->vinfo.depth);
+ pix = XCreatePixmap(xp->d, xp->w, xp->test_width, xp->test_height, xp->vinfo.depth);
pixgc = XCreateGC(xp->d, pix, 0, 0);
/* need a gc with GXcopy cos pixmaps contain junk on creation. mmm */
- XCopyArea(xp->d, xp->w, pix, pixgc, 0, 0, WIDTH, HEIGHT, 0, 0);
+ XCopyArea(xp->d, xp->w, pix, pixgc, 0, 0, xp->test_width, xp->test_height, 0, 0);
XFreeGC(xp->d, pixgc);
return reps;
}
@@ -212,9 +212,12 @@
{
(void) InitCopyWin(xp, p, reps);
+#if 1
+p->font=1;
/* Create image to stuff bits into */
- image = XGetImage(xp->d, xp->w, 0, 0, WIDTH, HEIGHT, xp->planemask,
+ image = XGetImage(xp->d, xp->w, 0, 0, xp->test_width, xp->test_height, xp->planemask,
p->font==0?ZPixmap:XYPixmap);
+#endif
if(image==0){
printf("XGetImage failed\n");
return False;
@@ -523,18 +526,18 @@
XGCValues gcv;
GC pixgc;
- InitBltLines();
+ InitBltLines(xp);
InitCopyLocations(xp, p, reps);
/* Create pixmap to write stuff into, and initialize it */
- pix = XCreatePixmap(xp->d, xp->w, WIDTH, HEIGHT,
+ pix = XCreatePixmap(xp->d, xp->w, xp->test_width, xp->test_height,
p->font==0 ? 1 : xp->vinfo.depth);
gcv.graphics_exposures = False;
gcv.foreground = 0;
gcv.background = 1;
pixgc = XCreateGC(xp->d, pix,
GCForeground | GCBackground | GCGraphicsExposures, &gcv);
- XFillRectangle(xp->d, pix, pixgc, 0, 0, WIDTH, HEIGHT);
+ XFillRectangle(xp->d, pix, pixgc, 0, 0, xp->test_width, xp->test_height);
gcv.foreground = 1;
gcv.background = 0;
XChangeGC(xp->d, pixgc, GCForeground | GCBackground, &gcv);
Index: do_complex.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/do_complex.c,v
retrieving revision 1.2
diff -u -r1.2 do_complex.c
--- do_complex.c 23 Apr 2004 19:54:38 -0000 1.2
+++ do_complex.c 22 Apr 2005 21:40:23 -0000
@@ -86,10 +86,10 @@
phi += phiinc;
y += 2 * iradius;
- if (y + iradius >= HEIGHT) {
+ if (y + iradius >= xp->test_height) {
y = iradius;
x += 2 * iradius;
- if (x + iradius >= WIDTH) {
+ if (x + iradius >= xp->test_width) {
x = iradius;
}
}
@@ -159,10 +159,10 @@
}
phi += phiinc;
y += 2 * iradius;
- if (y + iradius >= HEIGHT) {
+ if (y + iradius >= xp->test_height) {
y = iradius;
x += 2 * iradius;
- if (x + iradius >= WIDTH) {
+ if (x + iradius >= xp->test_width) {
x = iradius;
}
}
Index: do_lines.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/do_lines.c,v
retrieving revision 1.2
diff -u -r1.2 do_lines.c
--- do_lines.c 23 Apr 2004 19:54:38 -0000 1.2
+++ do_lines.c 22 Apr 2005 21:40:23 -0000
@@ -108,10 +108,10 @@
/* If off either top or bottom, backtrack to previous position and go
the other way instead. Also move in bigxdir if not already. */
rows++;
- if (y < half || y >= (HEIGHT-half) || rows > MAXROWS) {
+ if (y < half || y >= (xp->test_height-half) || rows > MAXROWS) {
rows = 0;
if (bigxdir > 0) {
- if (x + size < WIDTH - half) {
+ if (x + size < xp->test_width - half) {
xdir = 1;
} else {
bigxdir = -1;
@@ -133,10 +133,10 @@
need such adjustment, line length (in pixels) should not
change...we just can't get the slope we want for this line. */
if (y < half) {
- y = (HEIGHT - y1)/2;
+ y = (xp->test_height - y1)/2;
ydir = 1;
- } else if (y > (HEIGHT - half)) {
- y = (HEIGHT + y1)/2;
+ } else if (y > (xp->test_height - half)) {
+ y = (xp->test_height + y1)/2;
ydir = -1;
}
}
@@ -147,10 +147,10 @@
/* Again, if we are off the bottom then we can't really draw the line
we want. */
if (x < half) {
- x = (WIDTH - x1)/2;
+ x = (xp->test_width - x1)/2;
xdir = 1;
- } else if (x > (WIDTH - half)) {
- x = (WIDTH + x1)/2;
+ } else if (x > (xp->test_width - half)) {
+ x = (xp->test_width + x1)/2;
xdir = -1;
}
points[i].x = x;
Index: do_movewin.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/do_movewin.c,v
retrieving revision 1.2
diff -u -r1.2 do_movewin.c
--- do_movewin.c 23 Apr 2004 19:54:38 -0000 1.2
+++ do_movewin.c 22 Apr 2005 21:40:24 -0000
@@ -33,7 +33,7 @@
static int xmax, ymax;
static int delta1; /* Private global data for DoResizeWindows */
-#define STACK (4*(HEIGHT-10)/CHILDSIZE)
+#define STACK (4*(xp->test_height-10)/CHILDSIZE)
int
InitMoveWindows(XParms xp, Parms p, int reps)
@@ -72,9 +72,9 @@
for (i = 0; i != reps; i++) {
x_offset += 1;
y_offset += 3;
- if (y_offset + ymax > HEIGHT)
+ if (y_offset + ymax > xp->test_height)
y_offset = 0;
- if (x_offset + xmax > WIDTH)
+ if (x_offset + xmax > xp->test_width)
x_offset = 0;
for (j = 0; j != p->objects; j++) {
XMoveWindow(xp->d, children[j],
@@ -189,9 +189,9 @@
for (i = 0; i != reps; i++) {
x_offset += 1;
y_offset += 3;
- if (y_offset + ymax > HEIGHT)
+ if (y_offset + ymax > xp->test_height)
y_offset = 0;
- if (x_offset + xmax > WIDTH)
+ if (x_offset + xmax > xp->test_width)
x_offset = 0;
XMoveWindow(xp->d, cover, x_offset, y_offset);
CheckAbort ();
Index: do_rects.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/do_rects.c,v
retrieving revision 1.2
diff -u -r1.2 do_rects.c
--- do_rects.c 23 Apr 2004 19:54:38 -0000 1.2
+++ do_rects.c 22 Apr 2005 21:40:24 -0000
@@ -70,11 +70,11 @@
y += step;
rows++;
- if (y + size > HEIGHT || rows == MAXROWS) {
+ if (y + size > xp->test_height || rows == MAXROWS) {
rows = 0;
y = lw;
x += step;
- if (x + size > WIDTH) {
+ if (x + size > xp->test_width) {
x = lw;
}
}
Index: do_segs.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/do_segs.c,v
retrieving revision 1.2
diff -u -r1.2 do_segs.c
--- do_segs.c 23 Apr 2004 19:54:38 -0000 1.2
+++ do_segs.c 22 Apr 2005 21:40:24 -0000
@@ -140,12 +140,12 @@
/* Change square to draw segment in */
rows++;
y += size;
- if (y >= HEIGHT - size - half || rows == MAXROWS) {
+ if (y >= xp->test_height - size - half || rows == MAXROWS) {
/* Go to next column */
rows = 0;
y = half;
x += size;
- if (x >= WIDTH - size - half) {
+ if (x >= xp->test_width - size - half) {
x = half;
}
}
@@ -252,11 +252,11 @@
}
rows++;
y += size;
- if (y >= HEIGHT - size - half || rows == MAXROWS) {
+ if (y >= xp->test_height - size - half || rows == MAXROWS) {
rows = 0;
y = half;
x += size;
- if (x >= WIDTH - size - half)
+ if (x >= xp->test_width - size - half)
x = half;
}
}
@@ -325,12 +325,12 @@
}
rows++;
y += size;
- if (y >= HEIGHT - size - half || rows == MAXROWS) {
+ if (y >= xp->test_height - size - half || rows == MAXROWS) {
/* Go to next column */
rows = 0;
y = half;
x += size;
- if (x >= WIDTH - size - half) {
+ if (x >= xp->test_width - size - half) {
x = half;
}
}
Index: do_tests.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/do_tests.c,v
retrieving revision 1.3
diff -u -r1.3 do_tests.c
--- do_tests.c 6 Aug 2004 23:42:11 -0000 1.3
+++ do_tests.c 22 Apr 2005 21:40:28 -0000
@@ -925,85 +925,85 @@
{"-ftext", "Char in 80-char line (6x13)", NULL,
InitText, DoText, ClearTextWin, EndText,
V1_2FEATURE, ROP, 0,
- {80, False, "6x13", NULL}},
+ {80, False, "-misc-fixed-medium-r-semicondensed--*-120-*-*-c-0-iso8859-1,6x13", NULL}},
{"-f8text", "Char in 70-char line (8x13)", NULL,
InitText, DoText, ClearTextWin, EndText,
V1_3FEATURE, ROP, 0,
- {70, False, "8x13", NULL}},
+ {70, False, "-misc-fixed-medium-r-normal--*-120-*-*-c-0-iso8859-1,8x13", NULL}},
{"-f9text", "Char in 60-char line (9x15)", NULL,
InitText, DoText, ClearTextWin, EndText,
V1_3FEATURE, ROP, 0,
- {60, False, "9x15", NULL}},
+ {60, False, "-misc-fixed-medium-r-normal--*-140-*-*-c-0-iso8859-1,9x15", NULL}},
{"-f14text16", "Char16 in 40-char line (k14)", NULL,
InitText16, DoText16, ClearTextWin, EndText16,
V1_3FEATURE, ROP, 0,
{40, False,
- "-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-*",
+ "-misc-fixed-medium-r-normal--*-130-*-*-c-0-jisx0208.1983-*,-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-*",
NULL}},
{"-f24text16", "Char16 in 23-char line (k24)", NULL,
InitText16, DoText16, ClearTextWin, EndText16,
V1_3FEATURE, ROP, 0,
{23, False,
- "-jis-fixed-medium-r-normal--24-230-75-75-c-240-jisx0208.1983-*",
+ "-jis-fixed-medium-r-normal--*-230-*-*-c-0-jisx0208.1983-*,-jis-fixed-medium-r-normal--24-230-75-75-c-240-jisx0208.1983-*",
NULL}},
{"-tr10text", "Char in 80-char line (TR 10)", NULL,
InitText, DoText, ClearTextWin, EndText,
V1_2FEATURE, ROP, 0,
{80, False,
- "-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1",
+ "-adobe-times-medium-r-normal--*-100-*-*-p-0-iso8859-1,-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1",
NULL}},
{"-tr24text", "Char in 30-char line (TR 24)", NULL,
InitText, DoText, ClearTextWin, EndText,
V1_2FEATURE, ROP, 0,
{30, False,
- "-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1",
+ "-adobe-times-medium-r-normal--*-240-*-*-p-0-iso8859-1,-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1",
NULL}},
{"-polytext", "Char in 20/40/20 line (6x13, TR 10)", NULL,
InitText, DoPolyText, ClearTextWin, EndText,
V1_2FEATURE, ROP, 0,
{80, True, "6x13",
- "-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1"}},
+ "-adobe-times-medium-r-normal--*-100-*-*-p-0-iso8859-1,6x13"}},
{"-polytext16", "Char16 in 7/14/7 line (k14, k24)", NULL,
InitText16, DoPolyText16, ClearTextWin, EndText16,
V1_3FEATURE, ROP, 0,
{28, True,
- "-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-*",
- "-jis-fixed-medium-r-normal--24-230-75-75-c-240-jisx0208.1983-*"}},
+ "-misc-fixed-medium-r-normal--*-130-*-*-c-0-jisx0208.1983-*,-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-*",
+ "-jis-fixed-medium-r-normal--*-230-*-*-c-0-jisx0208.1983-*,-jis-fixed-medium-r-normal--24-230-75-75-c-240-jisx0208.1983-*"}},
{"-fitext", "Char in 80-char image line (6x13)", NULL,
InitText, DoImageText, ClearTextWin, EndText,
V1_2FEATURE, PLANEMASK, 0,
- {80, False, "6x13", NULL}},
+ {80, False, "-misc-fixed-medium-r-semicondensed--*-120-*-*-c-0-iso8859-1,6x13", NULL}},
{"-f8itext", "Char in 70-char image line (8x13)", NULL,
InitText, DoImageText, ClearTextWin, EndText,
V1_3FEATURE, PLANEMASK, 0,
- {70, False, "8x13", NULL}},
+ {70, False, "-misc-fixed-medium-r-normal--*-120-*-*-c-0-iso8859-1,8x13", NULL}},
{"-f9itext", "Char in 60-char image line (9x15)", NULL,
InitText, DoImageText, ClearTextWin, EndText,
V1_3FEATURE, PLANEMASK, 0,
- {60, False, "9x15", NULL}},
+ {60, False, "-misc-fixed-medium-r-normal--*-140-*-*-c-0-iso8859-1,9x15", NULL}},
{"-f14itext16", "Char16 in 40-char image line (k14)", NULL,
InitText16, DoImageText16, ClearTextWin, EndText16,
V1_3FEATURE, PLANEMASK, 0,
{40, False,
- "-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-*",
+ "-misc-fixed-medium-r-normal--*-130-*-*-c-0-jisx0208.1983-*,-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-*",
NULL}},
{"-f24itext16", "Char16 in 23-char image line (k24)", NULL,
InitText16, DoImageText16, ClearTextWin, EndText16,
V1_3FEATURE, PLANEMASK, 0,
{23, False,
- "-jis-fixed-medium-r-normal--24-230-75-75-c-240-jisx0208.1983-*",
+ "-jis-fixed-medium-r-normal--*-230-*-*-c-0-jisx0208.1983-*,-jis-fixed-medium-r-normal--24-230-75-75-c-240-jisx0208.1983-*",
NULL}},
{"-tr10itext", "Char in 80-char image line (TR 10)", NULL,
InitText, DoImageText, ClearTextWin, EndText,
V1_2FEATURE, PLANEMASK, 0,
{80, False,
- "-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1",
+ "-adobe-times-medium-r-normal--*-100-*-*-p-0-iso8859-1,-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1",
NULL}},
{"-tr24itext", "Char in 30-char image line (TR 24)", NULL,
InitText, DoImageText, ClearTextWin, EndText,
V1_2FEATURE, PLANEMASK, 0,
{30, False,
- "-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1",
+ "-adobe-times-medium-r-normal--*-240-*-*-p-0-iso8859-1,-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1",
NULL}},
#ifdef XFT
{"-aa10text", "Char in 80-char aa line (Charter 10)", NULL,
Index: do_text.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/do_text.c,v
retrieving revision 1.2
diff -u -r1.2 do_text.c
--- do_text.c 23 Apr 2004 19:54:38 -0000 1.2
+++ do_text.c 22 Apr 2005 21:40:29 -0000
@@ -35,6 +35,24 @@
#define XPOS 20
#define SEGS 3
+static
+XFontStruct *LoadQueryFontList(Display *d, char *list)
+{
+ char *s;
+ XFontStruct *f;
+ list = strdup(list);
+ s = strtok(list, ",");
+ while(s)
+ {
+ f = XLoadQueryFont(d, s);
+ if (f) {
+ free(list);
+ return f;
+ }
+ s = strtok(NULL, ",");
+ }
+ return NULL;
+}
int
InitText(XParms xp, Parms p, int reps)
@@ -43,7 +61,7 @@
char ch;
XGCValues gcv;
- font = XLoadQueryFont(xp->d, p->font);
+ font = LoadQueryFontList(xp->d, p->font);
if (font == NULL) {
printf("Could not load font '%s', benchmark omitted\n", p->font);
return 0;
@@ -51,15 +69,15 @@
bfont = NULL;
if (p->bfont != NULL) {
- bfont = XLoadQueryFont(xp->d, p->bfont);
+ bfont = LoadQueryFontList(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;
+ ypos = XPOS+height;
if (bfont != NULL) {
int h = (bfont->max_bounds.ascent + bfont->max_bounds.descent) + 1;
if (h > height)
@@ -129,7 +147,7 @@
int rows, columns, totalChars, ch;
int brows, bcolumns = 0, btotalChars = 0, bch = 0;
- font = XLoadQueryFont(xp->d, p->font);
+ font = LoadQueryFontList(xp->d, p->font);
if (font == NULL) {
printf("Could not load font '%s', benchmark omitted\n", p->font);
return 0;
@@ -142,7 +160,7 @@
bfont = NULL;
if (p->bfont != NULL) {
- bfont = XLoadQueryFont(xp->d, p->bfont);
+ bfont = LoadQueryFontList(xp->d, p->bfont);
if (bfont == NULL) {
printf("Could not load font '%s', benchmark omitted\n", p->bfont);
return 0;
@@ -154,8 +172,8 @@
if (brows > totalLines) totalLines = brows;
}
- ypos = XPOS;
height = (font->max_bounds.ascent + font->max_bounds.descent) + 1;
+ ypos = XPOS+height;
if (bfont != NULL) {
int h = (bfont->max_bounds.ascent + bfont->max_bounds.descent) + 1;
if (h > height)
@@ -230,9 +248,9 @@
XDrawString(
xp->d, xp->w, xp->fggc, XPOS, ypos, charBuf[line], charsPerLine);
ypos += height;
- if (ypos > HEIGHT - height) {
+ if (ypos > xp->test_height - height) {
/* Wraparound to top of window */
- ypos = XPOS;
+ ypos = XPOS+height;
line = startLine;
startLine = (startLine + 1) % totalLines;
}
@@ -252,9 +270,9 @@
XDrawString16(
xp->d, xp->w, xp->fggc, XPOS, ypos, (XChar2b *)charBuf[line], charsPerLine);
ypos += height;
- if (ypos > HEIGHT - height) {
+ if (ypos > xp->test_height - height) {
/* Wraparound to top of window */
- ypos = XPOS;
+ ypos = XPOS+height;
line = startLine;
startLine = (startLine + 1) % totalLines;
}
@@ -274,9 +292,9 @@
XDrawText(
xp->d, xp->w, xp->fggc, XPOS, ypos, &items[line*SEGS], SEGS);
ypos += height;
- if (ypos > HEIGHT - height) {
+ if (ypos > xp->test_height - height) {
/* Wraparound to top of window */
- ypos = XPOS;
+ ypos = XPOS+height;
line = startLine;
startLine = (startLine + 1) % totalLines;
}
@@ -296,9 +314,9 @@
XDrawText16(
xp->d, xp->w, xp->fggc, XPOS, ypos, (XTextItem16 *)&items[line*SEGS], SEGS);
ypos += height;
- if (ypos > HEIGHT - height) {
+ if (ypos > xp->test_height - height) {
/* Wraparound to top of window */
- ypos = XPOS;
+ ypos = XPOS+height;
line = startLine;
startLine = (startLine + 1) % totalLines;
}
@@ -318,9 +336,9 @@
XDrawImageString(
xp->d, xp->w, xp->fggc, XPOS, ypos, charBuf[line], charsPerLine);
ypos += height;
- if (ypos > HEIGHT - height) {
+ if (ypos > xp->test_height - height) {
/* Wraparound to top of window */
- ypos = XPOS;
+ ypos = XPOS+height;
startLine = (startLine + 17) % totalLines;
line = startLine;
}
@@ -340,9 +358,9 @@
XDrawImageString16(
xp->d, xp->w, xp->fggc, XPOS, ypos, (XChar2b *)charBuf[line], charsPerLine);
ypos += height;
- if (ypos > HEIGHT - height) {
+ if (ypos > xp->test_height - height) {
/* Wraparound to top of window */
- ypos = XPOS;
+ ypos = XPOS+height;
startLine = (startLine + 17) % totalLines;
line = startLine;
}
@@ -483,9 +501,9 @@
XftDrawString8 (aadraw, &aacolor, aafont,
XPOS, ypos, (unsigned char *) charBuf[line], charsPerLine);
ypos += height;
- if (ypos > HEIGHT - height) {
+ if (ypos > xp->test_height - height) {
/* Wraparound to top of window */
- ypos = XPOS;
+ ypos = XPOS+height;
line = startLine;
startLine = (startLine + 1) % totalLines;
}
Index: do_traps.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/do_traps.c,v
retrieving revision 1.4
diff -u -r1.4 do_traps.c
--- do_traps.c 11 Aug 2004 08:05:31 -0000 1.4
+++ do_traps.c 22 Apr 2005 21:40:29 -0000
@@ -65,11 +65,11 @@
y += size;
rows++;
- if (y + size > HEIGHT || rows == MAXROWS) {
+ if (y + size > xp->test_height || rows == MAXROWS) {
rows = 0;
y = 0;
x += 2 * size;
- if (x + size > WIDTH) {
+ if (x + size > xp->test_width) {
x = size;
}
}
@@ -171,7 +171,7 @@
}
maskFormat = XRenderFindStandardFormat (xp->d, std_fmt);
- maskPixmap = XCreatePixmap (xp->d, xp->w, WIDTH, HEIGHT, depth);
+ maskPixmap = XCreatePixmap (xp->d, xp->w, xp->test_width, xp->test_height, depth);
mask = XRenderCreatePicture (xp->d, maskPixmap, maskFormat, 0, 0);
@@ -217,11 +217,11 @@
y += size;
rows++;
- if (y + size > HEIGHT || rows == MAXROWS) {
+ if (y + size > xp->test_height || rows == MAXROWS) {
rows = 0;
y = 0;
x += 2 * size;
- if (x + size > WIDTH) {
+ if (x + size > xp->test_width) {
x = size;
}
}
@@ -244,10 +244,10 @@
src = black;
for (i = 0; i != reps; i++) {
XRenderFillRectangle (xp->d, PictOpSrc, mask, &transparent,
- 0, 0, WIDTH, HEIGHT);
+ 0, 0, xp->test_width, xp->test_height);
XRenderAddTraps (xp->d, mask, 0, 0, traps, p->objects);
XRenderComposite (xp->d, PictOpOver, src, mask, dst,
- 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+ 0, 0, 0, 0, 0, 0, xp->test_width, xp->test_height);
if (src == black)
src = white;
else
@@ -350,11 +350,11 @@
y += size;
rows++;
- if (y + size > HEIGHT || rows == MAXROWS) {
+ if (y + size > xp->test_height || rows == MAXROWS) {
rows = 0;
y = 0;
x += 2 * size;
- if (x + size > WIDTH) {
+ if (x + size > xp->test_width) {
x = size;
}
}
Index: do_tris.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/do_tris.c,v
retrieving revision 1.2
diff -u -r1.2 do_tris.c
--- do_tris.c 23 Apr 2004 19:54:38 -0000 1.2
+++ do_tris.c 22 Apr 2005 21:40:29 -0000
@@ -115,11 +115,11 @@
phi += phiinc;
y += 2 * iradius;
rows++;
- if (y + iradius > HEIGHT || rows == MAXROWS) {
+ if (y + iradius > xp->test_height || rows == MAXROWS) {
rows = 0;
y = iradius;
x += 2 * iradius;
- if (x + iradius > WIDTH) {
+ if (x + iradius > xp->test_width) {
x = iradius;
}
}
Index: do_windows.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/do_windows.c,v
retrieving revision 1.2
diff -u -r1.2 do_windows.c
--- do_windows.c 23 Apr 2004 19:54:38 -0000 1.2
+++ do_windows.c 22 Apr 2005 21:40:30 -0000
@@ -50,8 +50,8 @@
ComputeSizes(xp, p);
- parentcolumns = WIDTH / parentwidth;
- parentrows = HEIGHT / parentheight;
+ parentcolumns = xp->test_width / parentwidth;
+ parentrows = xp->test_height / parentheight;
parentwindows = parentcolumns * parentrows; /* Max reps we can fit */
if (parentwindows > reps) {
@@ -243,7 +243,7 @@
0, xp->foreground, xp->foreground);
#else
isolate = XCreateSimpleWindow(
- xp->d, xp->w, 0, 0, WIDTH, HEIGHT,
+ xp->d, xp->w, 0, 0, xp->test_width, xp->test_height,
0, xp->background, xp->background);
ComputeSizes(xp, p);
Index: x11perf.c
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/x11perf.c,v
retrieving revision 1.2
diff -u -r1.2 x11perf.c
--- x11perf.c 23 Apr 2004 19:54:38 -0000 1.2
+++ x11perf.c 22 Apr 2005 21:40:33 -0000
@@ -43,7 +43,9 @@
/* Only for working on ``fake'' servers, for hardware that doesn't exist */
static Bool drawToFakeServer = False;
static Pixmap tileToQuery = None;
-static char *displayName;
+static char *displayName,
+ *printerName,
+ *printFilename;
int abortTest;
typedef struct _RopNames { char *name; int rop; } RopNameRec, *RopNamePtr;
@@ -393,6 +395,125 @@
return(d);
}
+#ifdef XPRINT
+static
+void Open_Printer(char *printer_name, char *print_file)
+{
+ long dpi_x = 0L,
+ dpi_y = 0L;
+ XPPrinterList plist = NULL; /* list of printers */
+ int plist_count; /* number of entries in |plist|-array */
+ unsigned short dummy;
+ XRectangle winrect;
+
+ plist = XpuGetPrinterList(printer_name, &plist_count);
+
+ if (!plist) {
+ fprintf(stderr, "%s: no printers found for printer spec \"%s\".\n",
+ program_name, NULLSTR(printer_name));
+ exit(1);
+ }
+
+ printer_name = plist[0].name;
+
+ Log(("Using printer '%s'\n", printer_name));
+
+ if (XpuGetPrinter(printer_name, &xparms.d, &xparms.pcontext) != 1) {
+ fprintf(stderr, "%s: Cannot open printer '%s'\n", program_name, printer_name);
+ exit(1);
+ }
+
+ if (XpQueryExtension(xparms.d, &xparms.xp_event_base, &xparms.xp_error_base) == False) {
+ fprintf(stderr, "%s: XpQueryExtension() failed.\n", program_name);
+ XpuClosePrinterDisplay(xparms.d, xparms.pcontext);
+ exit(1);
+ }
+
+ /* Listen to XP(Start|End)(Job|Doc|Page)Notify events).
+ * This is mantatory as Xp(Start|End)(Job|Doc|Page) functions are _not_
+ * syncronous !!
+ * Not waiting for such events may cause that subsequent data may be
+ * destroyed/corrupted!!
+ */
+ XpSelectInput(xparms.d, xparms.pcontext, XPPrintMask);
+
+ /* Set job title */
+ XpuSetJobTitle(xparms.d, xparms.pcontext, "x11perf/Xprint");
+
+ /* Set print context
+ * Note that this modifies the available fonts, including builtin printer prints.
+ * All XListFonts()/XLoadFont() stuff should be done _after_ setting the print
+ * context to obtain the proper fonts.
+ */
+ XpSetContext(xparms.d, xparms.pcontext);
+
+ /* Get default printer reolution */
+ if (XpuGetResolution(xparms.d, xparms.pcontext, &dpi_x, &dpi_y) != 1) {
+ fprintf(stderr, "%s: No default resolution for printer '%s'.\n",
+ program_name, printer_name);
+ XpuClosePrinterDisplay(xparms.d, xparms.pcontext);
+ exit(1);
+ }
+
+ if (print_file) {
+ Log(("starting job (to file '%s').\n", print_file));
+ xparms.printtofile_handle = XpuStartJobToFile(xparms.d, xparms.pcontext, print_file);
+ if( !xparms.printtofile_handle ) {
+ fprintf(stderr, "%s: Error: %s while trying to print to file.\n",
+ program_name, strerror(errno));
+ XpuClosePrinterDisplay(xparms.d, xparms.pcontext);
+ exit(1);
+ }
+
+ XpuWaitForPrintNotify(xparms.d, xparms.xp_event_base, XPStartJobNotify);
+ }
+ else
+ {
+ Log(("starting job.\n"));
+ XpuStartJobToSpooler(xparms.d);
+ XpuWaitForPrintNotify(xparms.d, xparms.xp_event_base, XPStartJobNotify);
+ }
+
+ xparms.screen = XpGetScreenOfContext(xparms.d, xparms.pcontext);
+
+ /* Obtain some info about page geometry */
+ XpGetPageDimensions(xparms.d, xparms.pcontext, &dummy, &dummy, &winrect);
+
+ if (xparms.test_width == 0 &&
+ xparms.test_height == 0) {
+ xparms.test_x = winrect.x;
+ xparms.test_y = winrect.y;
+ xparms.test_width = winrect.width;
+ xparms.test_height = winrect.height;
+ }
+}
+
+static
+void PrintSpoolerCommandResults( Display *pdpy, XPContext pcontext )
+{
+ char *scr;
+
+ scr = XpGetOneAttribute(pdpy, pcontext, XPJobAttr, "xp-spooler-command-results");
+ if( scr )
+ {
+ if( strlen(scr) > 0 )
+ {
+ const char *msg = XpuCompoundTextToXmb(pdpy, scr);
+ if( msg )
+ {
+ Msg(("Spooler command returned '%s'.\n", msg));
+ XpuFreeXmbString(msg);
+ }
+ else
+ {
+ Msg(("Spooler command returned '%s' (unconverted).\n", scr));
+ }
+ }
+
+ XFree((void *)scr);
+ }
+}
+#endif /* XPRINT */
#ifdef SIGNALRETURNSINT
static int
@@ -428,6 +549,8 @@
static char *help_message[] = {
"where options include:",
" -display <host:display> the X server to contact",
+" -printer <name> name of printer to work on",
+" -printfile <filename> output file for print job",
" -sync do the tests in synchronous mode",
" -pack pack rectangles right next to each other",
" -repeat <n> do tests <n> times (default = 5)",
@@ -790,6 +913,11 @@
double time, totalTime;
int reps;
int j;
+
+ if (xp->pcontext) {
+ XpStartPage(xp->d, xp->w);
+ XpuWaitForPrintNotify(xp->d, xp->xp_event_base, XPStartPageNotify);
+ }
xp->planemask = pm;
CreatePerfGCs(xp, func, pm);
@@ -808,7 +936,7 @@
*/
if(reps == 0){
DestroyPerfGCs(xp);
- return;
+ goto done;
}
/* Create clip windows if requested */
CreateClipWindows(xp, test->clips);
@@ -836,6 +964,12 @@
printf ("\n");
fflush(stdout);
DestroyPerfGCs(xp);
+
+done:
+ if (xp->pcontext) {
+ XpEndPage(xp->d);
+ XpuWaitForPrintNotify(xp->d, xp->xp_event_base, XPEndPageNotify);
+ }
} /* ProcessTest */
#define Strstr strstr
@@ -868,6 +1002,8 @@
xparms.pack = False;
xparms.save_under = False;
xparms.backing_store = NotUseful;
+ xparms.test_width = 0; /* set to 0 means: use default */
+ xparms.test_height = 0; /* set to 0 means: use default */
/* Count number of tests */
ForEachTest(numTests);
@@ -878,7 +1014,18 @@
displayName = Get_Display_Name (&argc, argv);
xparms.version = GetVersion(&argc, argv);
for (i = 1; i != argc; i++) {
- if (strcmp (argv[i], "-all") == 0) {
+ if (strcmp (argv[i], "-printer") == 0) {
+ i++;
+ if (argc <= i)
+ usage ();
+ printerName = argv[i];
+ } else if (strcmp (argv[i], "-printfile") == 0) {
+ i++;
+ if (argc <= i)
+ usage ();
+ printFilename = argv[i];
+ } else
+ if (strcmp (argv[i], "-all") == 0) {
ForEachTest (j)
doit[j] = test[j].versions & xparms.version;
foundOne = True;
@@ -1109,8 +1256,26 @@
if (!foundOne)
usage ();
- xparms.d = Open_Display (displayName);
- screen = DefaultScreen(xparms.d);
+ if (displayName && printerName) {
+ fprintf (stderr, "%s: You cannot specify -display and -printer at the name time\n",
+ program_name);
+ exit(1);
+ }
+ if (printerName) {
+ Open_Printer(printerName, printFilename);
+ }
+ else
+ {
+ xparms.d = Open_Display (displayName);
+ xparms.screen = DefaultScreenOfDisplay(xparms.d);
+ }
+
+ screen = XScreenNumberOfScreen(xparms.screen);
+ if (xparms.test_width == 0 &&
+ xparms.test_height == 0) {
+ xparms.test_width = 1200;
+ xparms.test_height = 1200;
+ }
/* get visual info of default visual */
vmask = VisualIDMask | VisualScreenMask;
@@ -1212,20 +1377,27 @@
AllocateColor(xparms.d, background, WhitePixel(xparms.d, screen));
xparms.ddbackground =
AllocateColor(xparms.d, ddbackground, WhitePixel(xparms.d, screen));
- window_x = 2;
- if (DisplayWidth(xparms.d, screen) < WIDTH + window_x + 1)
- window_x = -1;
- window_y = 2;
- if (DisplayHeight(xparms.d, screen) < HEIGHT + window_y + 1)
- window_y = -1;
- xparms.w = CreatePerfWindow(&xparms, window_x, window_y, WIDTH, HEIGHT);
- HSx = WIDTH-1;
- if (window_x + 1 + WIDTH > DisplayWidth(xparms.d, screen))
+ if (xparms.pcontext) {
+ window_x = xparms.test_x;
+ window_y = xparms.test_y - (20+5); /* -room_for_status_window */
+ }
+ else
+ {
+ window_x = 2;
+ if (DisplayWidth(xparms.d, screen) < xparms.test_width + window_x + 1)
+ window_x = -1;
+ window_y = 2;
+ if (DisplayHeight(xparms.d, screen) < xparms.test_height + window_y + 1)
+ window_y = -1;
+ }
+ xparms.w = CreatePerfWindow(&xparms, window_x, window_y, xparms.test_width, xparms.test_height);
+ HSx = xparms.test_width-1;
+ if (window_x + 1 + xparms.test_width > DisplayWidth(xparms.d, screen))
HSx = DisplayWidth(xparms.d, screen) - (1 + window_x + 1);
- HSy = HEIGHT-1;
- if (window_y + 1 + HEIGHT > DisplayHeight(xparms.d, screen))
+ HSy = xparms.test_height-1;
+ if (window_y + 1 + xparms.test_height > DisplayHeight(xparms.d, screen))
HSy = DisplayHeight(xparms.d, screen) - (1 + window_y + 1);
- status = CreatePerfWindow(&xparms, window_x, HEIGHT+5, WIDTH, 20);
+ status = CreatePerfWindow(&xparms, window_x, xparms.test_height+5, xparms.test_width, 20);
tgcv.foreground =
AllocateColor(xparms.d, "black", BlackPixel(xparms.d, screen));
tgcv.background =
@@ -1241,7 +1413,7 @@
software cursor machines it will slow graphics performance. On
all current MIT-derived servers it will slow window
creation/configuration performance. */
- XWarpPointer(xparms.d, None, status, 0, 0, 0, 0, WIDTH+32, 20+32);
+ XWarpPointer(xparms.d, None, status, 0, 0, 0, 0, xparms.test_width+32, 20+32);
/* Figure out how long to call HardwareSync, so we can adjust for that
in our total elapsed time */
@@ -1320,7 +1492,31 @@
/* Restore ScreenSaver to original state. */
XSetScreenSaver(xparms.d, ssTimeout, ssInterval, ssPreferBlanking,
ssAllowExposures);
- XCloseDisplay(xparms.d);
+
+ if (xparms.pcontext) {
+ /* End the print job - the final results are sent by the X print
+ * server to the spooler sub system.
+ */
+ XpEndJob(xparms.d);
+ XpuWaitForPrintNotify(xparms.d, xparms.xp_event_base, XPEndJobNotify);
+ Log(("end job.\n"));
+
+ if (printFilename) {
+ if (XpuWaitForPrintFileChild(xparms.printtofile_handle) != XPGetDocFinished) {
+ fprintf(stderr, "%s: Error while printing to file.\n", program_name);
+ XpuClosePrinterDisplay(xparms.d, xparms.pcontext);
+ exit(1);
+ }
+ }
+
+ PrintSpoolerCommandResults(xparms.d, xparms.pcontext);
+
+ XpuClosePrinterDisplay(xparms.d, xparms.pcontext);
+ }
+ else
+ {
+ XCloseDisplay(xparms.d);
+ }
free(saveargv);
free(doit);
exit(0);
Index: x11perf.h
===================================================================
RCS file: /cvs/xorg/xc/programs/x11perf/x11perf.h,v
retrieving revision 1.3
diff -u -r1.3 x11perf.h
--- x11perf.h 6 Aug 2004 23:42:11 -0000 1.3
+++ x11perf.h 22 Apr 2005 21:40:34 -0000
@@ -34,15 +34,21 @@
#if defined(XlibSpecificationRelease) && XlibSpecificationRelease >= 5
#include <X11/Xfuncs.h>
#endif
+#ifdef XPRINT
+#include <X11/XprintUtil/xprintutil.h>
+#endif
+
#include <stddef.h>
+/* Turn a NULL pointer string into an empty string */
+#define NULLSTR(x) (((x)!=NULL)?(x):(""))
+#define Log(x) { printf x; }
+#define Msg(x) { printf x; }
+
#define POLY 1000 /* # (small) items in poly calls */
#define MAXROWS 40 /* Max rows of items in poly calls */
#define MAXCOLS 25 /* Max columns of items */
-#define WIDTH 600 /* Size of large window to work within */
-#define HEIGHT 600
-
#define CHILDSIZE 8 /* Size of children on windowing tests */
#define CHILDSPACE 4 /* Space between children */
@@ -74,6 +80,17 @@
typedef struct _XParms {
Display *d;
+ Screen *screen;
+#ifdef XPRINT
+ XPContext pcontext;
+ void *printtofile_handle; /* "context" when printing to file */
+ int xp_event_base, /* XpExtension even base */
+ xp_error_base; /* XpExtension error base */
+#endif
+ unsigned short test_x,
+ test_y;
+ unsigned long test_width,
+ test_height;
Window w;
Pixmap p;
GC fggc;
More information about the Xprint
mailing list