X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=blobdiff_plain;f=draw.c;h=0edf2308977afd7acf427eaa9b5b38fce02d0cbc;hp=874fcd884f7c7087a76ed6ac38cec858d11d77f1;hb=37266870c73e9be76c84d0f097ebee25ad17ebdf;hpb=a891a7c3889eb9959ae62c4fb255ec06e1aa1f9d diff --git a/draw.c b/draw.c index 874fcd8..0edf230 100644 --- a/draw.c +++ b/draw.c @@ -187,20 +187,6 @@ SelectPieces(VariantClass v) if(v == VariantChuChess) { pngPieceBitmaps[i][(int)WhiteNightrider] = pngPieceBitmaps2[i][(int)WhiteLion]; } - if(v == VariantChu) { - pngPieceBitmaps[i][(int)WhiteNightrider] = pngPieceBitmaps2[i][(int)WhiteClaw]; - pngPieceBitmaps[i][(int)WhiteClaw] = pngPieceBitmaps2[i][(int)WhiteNightrider]; - pngPieceBitmaps[i][(int)WhiteUnicorn] = pngPieceBitmaps2[i][(int)WhiteCat]; - pngPieceBitmaps[i][(int)WhiteSilver] = pngPieceBitmaps2[i][(int)WhiteSword]; - pngPieceBitmaps[i][(int)WhiteFalcon] = pngPieceBitmaps2[i][(int)WhiteDagger]; - pngPieceBitmaps[i][(int)WhiteCat] = pngPieceBitmaps2[i][(int)WhiteUnicorn]; - pngPieceBitmaps[i][(int)WhiteSword] = pngPieceBitmaps2[i][(int)WhiteSilver]; - pngPieceBitmaps[i][(int)WhiteDagger] = pngPieceBitmaps2[i][(int)WhiteFalcon]; - pngPieceBitmaps[i][(int)WhiteMan] = pngPieceBitmaps2[i][(int)WhiteCopper]; - pngPieceBitmaps[i][(int)WhiteCopper] = pngPieceBitmaps2[i][(int)WhiteMan]; - pngPieceBitmaps[i][(int)WhiteAxe] = pngPieceBitmaps2[i][(int)WhiteCannon]; - pngPieceBitmaps[i][(int)WhiteCannon] = pngPieceBitmaps2[i][(int)WhiteAxe]; - } } } @@ -269,7 +255,7 @@ ExposeRedraw (Option *graph, int x, int y, int w, int h) cairo_destroy(cr); } -static int modV[2], modH[2]; +static int modV[2], modH[2], transparency[2]; static void CreatePNGBoard (char *s, int kind) @@ -288,13 +274,14 @@ CreatePNGBoard (char *s, int kind) useTexture |= kind + 1; pngOriginalBoardBitmap[kind] = img; w = textureW[kind] = cairo_image_surface_get_width (img); h = textureH[kind] = cairo_image_surface_get_height (img); + transparency[kind] = cairo_image_surface_get_format (img) == CAIRO_FORMAT_ARGB32; n[kind] = 1.; modV[kind] = modH[kind] = -1; while((q = strchr(p+1, '-'))) p = q; // find last '-' if(strlen(p) < 11 && sscanf(p, "-%dx%d.pn%c", &f, &r, &c) == 3 && c == 'g') { if(f == 0 || r == 0) f = BOARD_WIDTH, r = BOARD_HEIGHT; // 0x0 means 'fits any', so make it fit textureW[kind] = (w*BOARD_WIDTH)/f; // sync cutting locations with square pattern textureH[kind] = (h*BOARD_HEIGHT)/r; - n[kind] = r*squareSize/h; // scale to make it fit exactly vertically + n[kind] = (r*squareSize + 0.99)/h; // scale to make it fit exactly vertically modV[kind] = r; modH[kind] = f; } else if((p = strstr(s, "xq")) && (p == s || p[-1] == '/')) { // assume full-board image for Xiangqi @@ -754,18 +741,13 @@ DrawLogo (Option *opt, void *logo) static void BlankSquare (cairo_surface_t *dest, int x, int y, int color, ChessSquare piece, int fac) { // [HGM] extra param 'fac' for forcing destination to (0,0) for copying to animation buffer - int x0, y0; + int x0, y0, texture = (useTexture & color+1) && CutOutSquare(x, y, &x0, &y0, color); cairo_t *cr; cr = cairo_create (dest); - if ((useTexture & color+1) && CutOutSquare(x, y, &x0, &y0, color)) { - cairo_set_source_surface (cr, pngBoardBitmap[color], x*fac - x0, y*fac - y0); - cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); - cairo_rectangle (cr, x*fac, y*fac, squareSize, squareSize); - cairo_fill (cr); - cairo_destroy (cr); - } else { // evenly colored squares + if(!texture || transparency[color]) // draw color also (as background) when texture could be transparent + { // evenly colored squares char *col = NULL; switch (color) { case 0: col = appData.darkSquareColor; break; @@ -777,8 +759,14 @@ BlankSquare (cairo_surface_t *dest, int x, int y, int color, ChessSquare piece, cairo_rectangle (cr, fac*x, fac*y, squareSize, squareSize); cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); cairo_fill (cr); - cairo_destroy (cr); } + if (texture) { + cairo_set_source_surface (cr, pngBoardBitmap[color], x*fac - x0, y*fac - y0); + cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); + cairo_rectangle (cr, x*fac, y*fac, squareSize, squareSize); + cairo_fill (cr); + } + cairo_destroy (cr); } static void