#define SOLID 0
#define OUTLINE 1
Boolean cairoAnimate = True;
-static cairo_surface_t *csBoardWindow;
+static cairo_surface_t *csBoardWindow, *csBoardBackup;
static cairo_surface_t *pngPieceBitmaps[2][(int)BlackPawn]; // scaled pieces as used
static cairo_surface_t *pngPieceBitmaps2[2][(int)BlackPawn+4]; // scaled pieces in store
static cairo_surface_t *pngBoardBitmap[2];
}
void
-DrawBorder (int x, int y, int type)
+DoDrawBorder (cairo_surface_t *cs, int x, int y, int type)
{
cairo_t *cr;
DrawSeekOpen();
- cr = cairo_create(csBoardWindow);
+ cr = cairo_create(cs);
cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
cairo_rectangle(cr, x, y, squareSize+lineGap, squareSize+lineGap);
SetPen(cr, lineGap, type == 1 ? appData.highlightSquareColor : appData.premoveHighlightColor, 0);
cairo_stroke(cr);
}
+void
+DrawBorder (int x, int y, int type)
+{
+ DoDrawBorder(csBoardWindow, x, y, type);
+ DoDrawBorder(csBoardBackup, x, y, type);
+}
+
static int
CutOutSquare (int x, int y, int *x0, int *y0, int kind)
{
cairo_rectangle (cr, x*fac, y*fac, squareSize, squareSize);
cairo_fill (cr);
cairo_destroy (cr);
+ if(fac) {
+ cr = cairo_create (csBoardBackup);
+ 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
XCopyArea(xDisplay, xpmBoardBitmap[color], dest, wlPieceGC, x0, y0,
squareSize, squareSize, x*fac, y*fac);
cairo_set_source_surface (cr, pngPieceBitmaps[kind][piece], x, y);
cairo_paint(cr);
cairo_destroy (cr);
+ cr = cairo_create (csBoardBackup);
+ cairo_set_source_surface (cr, pngPieceBitmaps[kind][piece], x, y);
+ cairo_paint(cr);
+ cairo_destroy (cr);
}
typedef void (*DrawFunc)();
}
void
-DrawDot (int marker, int x, int y, int r)
+DoDrawDot (int marker, int x, int y, int r, cairo_surface_t *cs)
{
cairo_t *cr;
DrawSeekOpen();
- cr = cairo_create(csBoardWindow);
+ cr = cairo_create(cs);
cairo_arc(cr, x+r/2, y+r/2, r/2, 0.0, 2*M_PI);
if(appData.monoMode) {
SetPen(cr, 2, marker == 2 ? "#000000" : "#FFFFFF", 0);
}
void
+DrawDot (int marker, int x, int y, int r)
+{
+ DoDrawDot(marker, x, y, r, csBoardWindow);
+ DoDrawDot(marker, x, y, r, csBoardBackup);
+}
+
+void
DrawOneSquare (int x, int y, ChessSquare piece, int square_color, int marker, char *string, int align)
{ // basic front-end board-draw function: takes care of everything that can be in square:
// piece, background, coordinate/count, marker dot
{
int boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap);
int boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap);
- if(!csBoardWindow) csBoardWindow = cairo_xlib_surface_create(xDisplay, xBoardWindow, DefaultVisual(xDisplay, 0), boardWidth, boardHeight);
+ if(!csBoardWindow) {
+ csBoardWindow = cairo_xlib_surface_create(xDisplay, xBoardWindow, DefaultVisual(xDisplay, 0), boardWidth, boardHeight);
+ csBoardBackup = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, boardWidth, boardHeight);
+ }
}
void
}
void
-DrawGrid()
+DoDrawGrid(cairo_surface_t *cs)
{
/* draws a grid starting around Nx, Ny squares starting at x,y */
int i;
DrawSeekOpen();
/* get a cairo_t */
- cr = cairo_create (csBoardWindow);
+ cr = cairo_create (cs);
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
SetPen(cr, lineGap, "#000000", 0);
return;
}
+void
+DrawGrid()
+{
+ DoDrawGrid(csBoardWindow);
+ DoDrawGrid(csBoardBackup);
+}
+
/*
* event handler for redrawing the board
*/
int srcX, int srcY, int width, int height, int destX, int destY)
{
if(cairoAnimate) {
- cairo_t *cr = cairo_create (c_animBufs[anr+destBuf]);
+ cairo_t *cr;// = cairo_create (c_animBufs[anr+destBuf]);
+ cr = cairo_create (c_animBufs[anr+destBuf]);
+ if(c_animBufs[anr+srcBuf] == csBoardWindow)
+ cairo_set_source_surface (cr, csBoardBackup, destX - srcX, destY - srcY);
+ else
+ cairo_set_source_surface (cr, c_animBufs[anr+srcBuf], destX - srcX, destY - srcY);
+ cairo_rectangle (cr, destX, destY, width, height);
+ cairo_fill (cr);
+ cairo_destroy (cr);
+ if(c_animBufs[anr+destBuf] == csBoardWindow) {
+ cr = cairo_create (csBoardBackup); // also draw to backup
cairo_set_source_surface (cr, c_animBufs[anr+srcBuf], destX - srcX, destY - srcY);
cairo_rectangle (cr, destX, destY, width, height);
cairo_fill (cr);
cairo_destroy (cr);
+ }
} else
XCopyArea(xDisplay, animBufs[anr+srcBuf], animBufs[anr+destBuf], animGCs[anr],
srcX, srcY, width, height, destX, destY);