XGetImage request will correctly fail and terminate x11perf with a BadMatch error if window is larger than its backing pixmap.
This change makes all tests from putimage10 to getimagexy500 work on screens that are smaller than the default window size. Signed-off-by: Rami Ylimäki <rami.ylim...@vincit.fi> --- do_arcs.c | 12 ++++++------ do_blt.c | 36 ++++++++++++++++++------------------ do_complex.c | 8 ++++---- do_lines.c | 16 ++++++++-------- do_movewin.c | 10 +++++----- do_rects.c | 4 ++-- do_segs.c | 12 ++++++------ do_text.c | 14 +++++++------- do_traps.c | 18 +++++++++--------- do_tris.c | 4 ++-- do_windows.c | 6 +++--- x11perf.c | 24 +++++++++++++++--------- x11perf.h | 5 ++--- 13 files changed, 87 insertions(+), 82 deletions(-) diff --git a/do_arcs.c b/do_arcs.c index 5c5f1ba..63eda65 100644 --- a/do_arcs.c +++ b/do_arcs.c @@ -69,16 +69,16 @@ GenerateCircles(XParms xp, Parms p, Bool partialArcs, Bool ddashed) y += size + 1; rows++; - if (y >= HEIGHT - size - half || rows == MAXROWS) { + if (y >= windowHeight - size - half || rows == MAXROWS) { /* Go to next column */ rows = 0; x += size + 1; - if (x >= WIDTH - size) { + if (x >= windowWidth - size) { yorg++; - if (yorg >= size + half || yorg >= HEIGHT - size - half) { + if (yorg >= size + half || yorg >= windowHeight - size - half) { yorg = half; xorg++; - if (xorg >= size + half || xorg >= WIDTH - size - half) { + if (xorg >= size + half || xorg >= windowWidth - size - half) { xorg = half; } } @@ -287,12 +287,12 @@ GenerateEllipses(XParms xp, Parms p, int partialArcs, Bool ddashed) y += size + 1; rows++; - if (y >= HEIGHT - size - half || rows == MAXROWS) { + if (y >= windowHeight - size - half || rows == MAXROWS) { /* Go to next column */ rows = 0; y = half; x += size + 1; - if (x >= WIDTH - size - half) { + if (x >= windowWidth - size - half) { x = half; } } diff --git a/do_blt.c b/do_blt.c index f843ae5..4be2836 100644 --- a/do_blt.c +++ b/do_blt.c @@ -41,22 +41,22 @@ InitBltLines(void) 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 = windowWidth-1; } else { points[i].x = 0; } - y += HEIGHT / (NUMPOINTS/2); + y += windowHeight / (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 = windowHeight-1; } else { points[i].y = 0; } - x += WIDTH / (NUMPOINTS/2); + x += windowWidth / (NUMPOINTS/2); points[i].x = x; } } @@ -91,18 +91,18 @@ DoScroll(XParms xp, Parms p, int reps) 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 > windowHeight) { yorg += delta; - if (yorg >= size || yorg + size + delta > HEIGHT) { + if (yorg >= size || yorg + size + delta > windowHeight) { yorg = 0; xorg++; - if (xorg >= size || xorg + size > WIDTH) { + if (xorg >= size || xorg + size > windowWidth) { xorg = 0; } } y = yorg; x += size; - if (x + size > WIDTH) { + if (x + size > windowWidth) { x = xorg; } } @@ -138,8 +138,8 @@ InitCopyLocations(XParms xp, Parms p, int reps) xinc = (size & ~3) + 1; yinc = xinc + 3; - width = (WIDTH - size) & ~31; - height = (HEIGHT - size) & ~31; + width = (windowWidth - size) & ~31; + height = (windowHeight - size) & ~31; x1 = 0; y1 = 0; @@ -197,10 +197,10 @@ InitCopyPix(XParms xp, Parms p, int reps) (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, windowWidth, windowHeight, xp->vinfo.depth); pixgc = XCreateGC(xp->d, pix, 0, NULL); /* 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, windowWidth, windowHeight, 0, 0); XFreeGC(xp->d, pixgc); return reps; } @@ -211,7 +211,7 @@ InitGetImage(XParms xp, Parms p, int reps) (void) InitCopyWin(xp, p, reps); /* 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, windowWidth, windowHeight, xp->planemask, p->font==NULL?ZPixmap:XYPixmap); if(image==NULL){ printf("XGetImage failed\n"); @@ -569,14 +569,14 @@ InitCopyPlane(XParms xp, Parms p, int reps) 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, windowWidth, windowHeight, p->font==NULL ? 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, windowWidth, windowHeight); gcv.foreground = 1; gcv.background = 0; XChangeGC(xp->d, pixgc, GCForeground | GCBackground, &gcv); @@ -657,17 +657,17 @@ InitCompositePix(XParms xp, Parms p, int reps) if (!format) format = XRenderFindStandardFormat (xp->d, xp->planemask); - pix = XCreatePixmap(xp->d, xp->w, WIDTH, HEIGHT, depth); + pix = XCreatePixmap(xp->d, xp->w, windowWidth, windowHeight, depth); pixPict = XRenderCreatePicture (xp->d, pix, format, 0, NULL); XRenderComposite (xp->d, PictOpClear, winPict, None, pixPict, - 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT); + 0, 0, 0, 0, 0, 0, windowWidth, windowHeight); #if 1 XRenderComposite (xp->d, PictOpOver, winPict, None, pixPict, - 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT); + 0, 0, 0, 0, 0, 0, windowWidth, windowHeight); #endif return reps; } diff --git a/do_complex.c b/do_complex.c index 3eac738..891dfee 100644 --- a/do_complex.c +++ b/do_complex.c @@ -84,10 +84,10 @@ InitComplexPoly(XParms xp, Parms p, int reps) phi += phiinc; y += 2 * iradius; - if (y + iradius >= HEIGHT) { + if (y + iradius >= windowHeight) { y = iradius; x += 2 * iradius; - if (x + iradius >= WIDTH) { + if (x + iradius >= windowWidth) { x = iradius; } } @@ -157,10 +157,10 @@ InitGeneralPoly(XParms xp, Parms p, int reps) } phi += phiinc; y += 2 * iradius; - if (y + iradius >= HEIGHT) { + if (y + iradius >= windowHeight) { y = iradius; x += 2 * iradius; - if (x + iradius >= WIDTH) { + if (x + iradius >= windowWidth) { x = iradius; } } diff --git a/do_lines.c b/do_lines.c index 88a1ebd..6c5f511 100644 --- a/do_lines.c +++ b/do_lines.c @@ -106,10 +106,10 @@ GenerateLines(XParms xp, Parms p, Bool ddashed) /* 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 >= (windowHeight-half) || rows > MAXROWS) { rows = 0; if (bigxdir > 0) { - if (x + size < WIDTH - half) { + if (x + size < windowWidth - half) { xdir = 1; } else { bigxdir = -1; @@ -131,10 +131,10 @@ GenerateLines(XParms xp, Parms p, Bool ddashed) 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 = (windowHeight - y1)/2; ydir = 1; - } else if (y > (HEIGHT - half)) { - y = (HEIGHT + y1)/2; + } else if (y > (windowHeight - half)) { + y = (windowHeight + y1)/2; ydir = -1; } } @@ -145,10 +145,10 @@ GenerateLines(XParms xp, Parms p, Bool ddashed) /* 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 = (windowWidth - x1)/2; xdir = 1; - } else if (x > (WIDTH - half)) { - x = (WIDTH + x1)/2; + } else if (x > (windowWidth - half)) { + x = (windowWidth + x1)/2; xdir = -1; } points[i].x = x; diff --git a/do_movewin.c b/do_movewin.c index ed96ae1..bb24dfb 100644 --- a/do_movewin.c +++ b/do_movewin.c @@ -31,7 +31,7 @@ static int x_offset, y_offset; /* Private global data for DoMoveWindows */ static int xmax, ymax; static int delta1; /* Private global data for DoResizeWindows */ -#define STACK (4*(HEIGHT-10)/CHILDSIZE) +#define STACK (4*(windowHeight-10)/CHILDSIZE) int InitMoveWindows(XParms xp, Parms p, int reps) @@ -70,9 +70,9 @@ DoMoveWindows(XParms xp, Parms p, int reps) for (i = 0; i != reps; i++) { x_offset += 1; y_offset += 3; - if (y_offset + ymax > HEIGHT) + if (y_offset + ymax > windowHeight) y_offset = 0; - if (x_offset + xmax > WIDTH) + if (x_offset + xmax > windowWidth) x_offset = 0; for (j = 0; j != p->objects; j++) { XMoveWindow(xp->d, children[j], @@ -187,9 +187,9 @@ DoMoveTree(XParms xp, Parms p, int reps) for (i = 0; i != reps; i++) { x_offset += 1; y_offset += 3; - if (y_offset + ymax > HEIGHT) + if (y_offset + ymax > windowHeight) y_offset = 0; - if (x_offset + xmax > WIDTH) + if (x_offset + xmax > windowWidth) x_offset = 0; XMoveWindow(xp->d, cover, x_offset, y_offset); CheckAbort (); diff --git a/do_rects.c b/do_rects.c index f697cdb..9ad7e13 100644 --- a/do_rects.c +++ b/do_rects.c @@ -68,11 +68,11 @@ InitRectangles(XParms xp, Parms p, int reps) y += step; rows++; - if (y + size > HEIGHT || rows == MAXROWS) { + if (y + size > windowHeight || rows == MAXROWS) { rows = 0; y = lw; x += step; - if (x + size > WIDTH) { + if (x + size > windowWidth) { x = lw; } } diff --git a/do_segs.c b/do_segs.c index bc13fbd..7e93116 100644 --- a/do_segs.c +++ b/do_segs.c @@ -138,12 +138,12 @@ GenerateSegments(XParms xp, Parms p, Bool ddashed) /* Change square to draw segment in */ rows++; y += size; - if (y >= HEIGHT - size - half || rows == MAXROWS) { + if (y >= windowHeight - size - half || rows == MAXROWS) { /* Go to next column */ rows = 0; y = half; x += size; - if (x >= WIDTH - size - half) { + if (x >= windowWidth - size - half) { x = half; } } @@ -250,11 +250,11 @@ InitHorizSegments(XParms xp, Parms p, int reps) } rows++; y += size; - if (y >= HEIGHT - size - half || rows == MAXROWS) { + if (y >= windowHeight - size - half || rows == MAXROWS) { rows = 0; y = half; x += size; - if (x >= WIDTH - size - half) + if (x >= windowWidth - size - half) x = half; } } @@ -323,12 +323,12 @@ InitVertSegments(XParms xp, Parms p, int reps) } rows++; y += size; - if (y >= HEIGHT - size - half || rows == MAXROWS) { + if (y >= windowHeight - size - half || rows == MAXROWS) { /* Go to next column */ rows = 0; y = half; x += size; - if (x >= WIDTH - size - half) { + if (x >= windowWidth - size - half) { x = half; } } diff --git a/do_text.c b/do_text.c index 6b41201..ca96526 100644 --- a/do_text.c +++ b/do_text.c @@ -228,7 +228,7 @@ DoText(XParms xp, Parms p, int reps) XDrawString( xp->d, xp->w, xp->fggc, XPOS, ypos, charBuf[line], charsPerLine); ypos += height; - if (ypos > HEIGHT - height) { + if (ypos > windowHeight - height) { /* Wraparound to top of window */ ypos = XPOS; line = startLine; @@ -250,7 +250,7 @@ DoText16(XParms xp, Parms p, int reps) XDrawString16( xp->d, xp->w, xp->fggc, XPOS, ypos, (XChar2b *)charBuf[line], charsPerLine); ypos += height; - if (ypos > HEIGHT - height) { + if (ypos > windowHeight - height) { /* Wraparound to top of window */ ypos = XPOS; line = startLine; @@ -272,7 +272,7 @@ DoPolyText(XParms xp, Parms p, int reps) XDrawText( xp->d, xp->w, xp->fggc, XPOS, ypos, &items[line*SEGS], SEGS); ypos += height; - if (ypos > HEIGHT - height) { + if (ypos > windowHeight - height) { /* Wraparound to top of window */ ypos = XPOS; line = startLine; @@ -294,7 +294,7 @@ DoPolyText16(XParms xp, Parms p, int reps) XDrawText16( xp->d, xp->w, xp->fggc, XPOS, ypos, (XTextItem16 *)&items[line*SEGS], SEGS); ypos += height; - if (ypos > HEIGHT - height) { + if (ypos > windowHeight - height) { /* Wraparound to top of window */ ypos = XPOS; line = startLine; @@ -316,7 +316,7 @@ DoImageText(XParms xp, Parms p, int reps) XDrawImageString( xp->d, xp->w, xp->fggc, XPOS, ypos, charBuf[line], charsPerLine); ypos += height; - if (ypos > HEIGHT - height) { + if (ypos > windowHeight - height) { /* Wraparound to top of window */ ypos = XPOS; startLine = (startLine + 17) % totalLines; @@ -338,7 +338,7 @@ DoImageText16(XParms xp, Parms p, int reps) XDrawImageString16( xp->d, xp->w, xp->fggc, XPOS, ypos, (XChar2b *)charBuf[line], charsPerLine); ypos += height; - if (ypos > HEIGHT - height) { + if (ypos > windowHeight - height) { /* Wraparound to top of window */ ypos = XPOS; startLine = (startLine + 17) % totalLines; @@ -481,7 +481,7 @@ DoAAText(XParms xp, Parms p, int reps) XftDrawString8 (aadraw, &aacolor, aafont, XPOS, ypos, (unsigned char *) charBuf[line], charsPerLine); ypos += height; - if (ypos > HEIGHT - height) { + if (ypos > windowHeight - height) { /* Wraparound to top of window */ ypos = XPOS; line = startLine; diff --git a/do_traps.c b/do_traps.c index 05f43c2..b0cecef 100644 --- a/do_traps.c +++ b/do_traps.c @@ -63,11 +63,11 @@ InitTrapezoids(XParms xp, Parms p, int reps) y += size; rows++; - if (y + size > HEIGHT || rows == MAXROWS) { + if (y + size > windowHeight || rows == MAXROWS) { rows = 0; y = 0; x += 2 * size; - if (x + size > WIDTH) { + if (x + size > windowWidth) { x = size; } } @@ -169,7 +169,7 @@ InitFixedTraps(XParms xp, Parms p, int reps) } maskFormat = XRenderFindStandardFormat (xp->d, std_fmt); - maskPixmap = XCreatePixmap (xp->d, xp->w, WIDTH, HEIGHT, depth); + maskPixmap = XCreatePixmap (xp->d, xp->w, windowWidth, windowHeight, depth); mask = XRenderCreatePicture (xp->d, maskPixmap, maskFormat, 0, NULL); @@ -215,11 +215,11 @@ InitFixedTraps(XParms xp, Parms p, int reps) y += size; rows++; - if (y + size > HEIGHT || rows == MAXROWS) { + if (y + size > windowHeight || rows == MAXROWS) { rows = 0; y = 0; x += 2 * size; - if (x + size > WIDTH) { + if (x + size > windowWidth) { x = size; } } @@ -242,10 +242,10 @@ DoFixedTraps(XParms xp, Parms p, int reps) src = black; for (i = 0; i != reps; i++) { XRenderFillRectangle (xp->d, PictOpSrc, mask, &transparent, - 0, 0, WIDTH, HEIGHT); + 0, 0, windowWidth, windowHeight); 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, windowWidth, windowHeight); if (src == black) src = white; else @@ -348,11 +348,11 @@ InitFixedTrapezoids(XParms xp, Parms p, int reps) y += size; rows++; - if (y + size > HEIGHT || rows == MAXROWS) { + if (y + size > windowHeight || rows == MAXROWS) { rows = 0; y = 0; x += 2 * size; - if (x + size > WIDTH) { + if (x + size > windowWidth) { x = size; } } diff --git a/do_tris.c b/do_tris.c index cf0200e..035f28b 100644 --- a/do_tris.c +++ b/do_tris.c @@ -113,11 +113,11 @@ InitTriangles(XParms xp, Parms p, int reps) phi += phiinc; y += 2 * iradius; rows++; - if (y + iradius > HEIGHT || rows == MAXROWS) { + if (y + iradius > windowHeight || rows == MAXROWS) { rows = 0; y = iradius; x += 2 * iradius; - if (x + iradius > WIDTH) { + if (x + iradius > windowWidth) { x = iradius; } } diff --git a/do_windows.c b/do_windows.c index 024d76b..365a201 100644 --- a/do_windows.c +++ b/do_windows.c @@ -48,8 +48,8 @@ CreateParents(XParms xp, Parms p, int reps) ComputeSizes(xp, p); - parentcolumns = WIDTH / parentwidth; - parentrows = HEIGHT / parentheight; + parentcolumns = windowWidth / parentwidth; + parentrows = windowHeight / parentheight; parentwindows = parentcolumns * parentrows; /* Max reps we can fit */ if (parentwindows > reps) { @@ -241,7 +241,7 @@ InitPopups(XParms xp, Parms p, int reps) 0, xp->foreground, xp->foreground); #else isolate = XCreateSimpleWindow( - xp->d, xp->w, 0, 0, WIDTH, HEIGHT, + xp->d, xp->w, 0, 0, windowWidth, windowHeight, 0, xp->background, xp->background); ComputeSizes(xp, p); diff --git a/x11perf.c b/x11perf.c index c5129d7..96ec2af 100644 --- a/x11perf.c +++ b/x11perf.c @@ -44,6 +44,8 @@ static Bool falsePrecision = False; static Pixmap tileToQuery = None; static char *displayName; int abortTest; +int windowWidth = 600; +int windowHeight = 600; typedef struct _RopNames { char *name; int rop; } RopNameRec, *RopNamePtr; @@ -1189,6 +1191,10 @@ main(int argc, char *argv[]) usage (); xparms.d = Open_Display (displayName); screen = DefaultScreen(xparms.d); + if (windowWidth > DisplayWidth(xparms.d, screen)) + windowWidth = DisplayWidth(xparms.d, screen); + if (windowHeight > DisplayHeight(xparms.d, screen)) + windowHeight = DisplayHeight(xparms.d, screen); /* get visual info of default visual */ vmask = VisualIDMask | VisualScreenMask; @@ -1291,19 +1297,19 @@ main(int argc, char *argv[]) xparms.ddbackground = AllocateColor(xparms.d, ddbackground, WhitePixel(xparms.d, screen)); window_x = 2; - if (DisplayWidth(xparms.d, screen) < WIDTH + window_x + 1) + if (DisplayWidth(xparms.d, screen) < windowWidth + window_x + 1) window_x = -1; window_y = 2; - if (DisplayHeight(xparms.d, screen) < HEIGHT + window_y + 1) + if (DisplayHeight(xparms.d, screen) < windowHeight + 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)) + xparms.w = CreatePerfWindow(&xparms, window_x, window_y, windowWidth, windowHeight); + HSx = windowWidth-1; + if (window_x + 1 + windowWidth > 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 = windowHeight-1; + if (window_y + 1 + windowHeight > 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, windowHeight+5, windowWidth, 20); tgcv.foreground = AllocateColor(xparms.d, "black", BlackPixel(xparms.d, screen)); tgcv.background = @@ -1319,7 +1325,7 @@ main(int argc, char *argv[]) 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, windowWidth+32, 20+32); /* Figure out how long to call HardwareSync, so we can adjust for that in our total elapsed time */ diff --git a/x11perf.h b/x11perf.h index 3cbb631..a31782e 100644 --- a/x11perf.h +++ b/x11perf.h @@ -43,9 +43,6 @@ SOFTWARE. #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 */ @@ -134,6 +131,8 @@ extern int NullInitProc(XParms xp, Parms p, int reps); extern Test test[]; extern int abortTest; +extern int windowWidth; /* Size of large window to work within */ +extern int windowHeight; extern void AbortTest (void); -- 1.6.3.3 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel