X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=draw.c;h=757185099605e114a3953d1cd295cab5df83a3ed;hb=67b3a0d7c465522feb67841c7374bf863df19357;hp=45a332c626ec3403390ec3535222e1bcfb88810d;hpb=4ca3b41e1ccb5ebfade606202c2084f8e9328978;p=xboard.git diff --git a/draw.c b/draw.c index 45a332c..7571850 100644 --- a/draw.c +++ b/draw.c @@ -110,7 +110,8 @@ extern char *getenv(); #define SOLID 0 #define OUTLINE 1 Boolean cairoAnimate; -static cairo_surface_t *csBoardWindow, *csBoardBackup, *csDualBoard; +Option *currBoard; +static cairo_surface_t *csBoardWindow; static cairo_surface_t *pngPieceImages[2][(int)BlackPawn+4]; // png 256 x 256 images 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 @@ -131,25 +132,9 @@ static int dual = 0; void SwitchWindow () { - cairo_surface_t *cstmp = csBoardWindow; - csBoardWindow = csDualBoard; dual = !dual; - if(!csDualBoard) { - csBoardWindow = GetOutputSurface(&dualOptions[3], 0, 0); - dual = 1; - } - csDualBoard = cstmp; -} - -void -NewSurfaces () -{ -return; - // delete surfaces after size becomes invalid, so they will be recreated - if(csBoardWindow) cairo_surface_destroy(csBoardWindow); - if(csBoardBackup) cairo_surface_destroy(csBoardBackup); - if(csDualBoard) cairo_surface_destroy(csDualBoard); - csBoardWindow = csBoardBackup = csDualBoard = NULL; + currBoard = (dual ? &mainOptions[W_BOARD] : &dualOptions[3]); + csBoardWindow = DRAWABLE(currBoard); } #define BoardSize int @@ -176,7 +161,6 @@ InitDrawingSizes (BoardSize boardSize, int flags) oldWidth = boardWidth; oldHeight = boardHeight; CreateGrid(); - NewSurfaces(); /* * Inhibit shell resizing. @@ -449,6 +433,7 @@ void DrawSeekOpen () { csBoardWindow = (cairo_surface_t *) mainOptions[W_BOARD].choice; + currBoard = &mainOptions[W_BOARD]; } void @@ -528,7 +513,7 @@ DrawBorder (int x, int y, int type) SetPen(cr, lineGap, col, 0); cairo_stroke(cr); cairo_destroy(cr); - DrawExpose(NULL, x, y, squareSize+2*lineGap, squareSize+2*lineGap); + GraphExpose(currBoard, x - lineGap/2, y - lineGap/2, squareSize+2*lineGap, squareSize+2*lineGap); } static int @@ -550,24 +535,23 @@ CutOutSquare (int x, int y, int *x0, int *y0, int kind) } void -DrawLogo (void *handle, void *logo) +DrawLogo (Option *opt, void *logo) { - cairo_surface_t *img, *cs; + cairo_surface_t *img; cairo_t *cr; int w, h; - if(!logo || !handle) return; - cs = GetOutputSurface(handle, appData.logoSize, appData.logoSize/2); + if(!logo || !opt) return; img = cairo_image_surface_create_from_png (logo); w = cairo_image_surface_get_width (img); h = cairo_image_surface_get_height (img); - cr = cairo_create(cs); + cr = cairo_create(DRAWABLE(opt)); cairo_scale(cr, (float)appData.logoSize/w, appData.logoSize/(2.*h)); cairo_set_source_surface (cr, img, 0, 0); cairo_paint (cr); cairo_destroy (cr); cairo_surface_destroy (img); - cairo_surface_destroy (cs); + GraphExpose(opt, 0, 0, appData.logoSize, appData.logoSize/2); } static void @@ -755,7 +739,7 @@ void CopyRectangle (AnimNr anr, int srcBuf, int destBuf, cairo_fill (cr); cairo_destroy (cr); if(c_animBufs[anr+destBuf] == csBoardWindow) - DrawExpose(NULL, destX, destY, squareSize, squareSize); + GraphExpose(currBoard, destX, destY, squareSize, squareSize); } void