Re: new developer release with cairo integration

"h.g. muller" <[email protected]>
Newsgroups gmane.comp.gnu.xboard.devel
Message-ID <[email protected]>
At 22:58 21-10-2012 -0700, Adrian Petrescu wrote:
>Okay, a bit of a deeper problem.
>
>I've successfully built it on OS X. If I run it with my old .xboardrc, it 
>displays a blank board and complains that the old -pixmapDirectory and 
>-bitmapDirectory arguments are no longer recognized. Fair enough, it's SVG 
>now. So I provide "-pieceImageDirectory ./svg" (from the build root), and 
>it crashes on startup with the error:
>
>Assertion failed: (_cairo_status_is_error (status)), function 
>_cairo_error, file cairo-error.c, line 68.
>
>It if helps, my version of cairo is 1.12.4.

This seems to be an OSX-specific problem. A similar behavior was reported 
by another Mac user:

http://www.talkchess.com/forum/viewtopic.php?t=45640&postdays=0&postorder=as 
c&topic_view=&start=10

In that forum thread I suggested to put in a few printf statements to 
figure out what was going on,
but I could find no obvious error. (I.e. there were no NULL pointers for 
any of the cairo objects,
and all pointers had reasonable values.) It seems the cairo surfaces get 
somehow corrupted,
and that the corruption propagates as one is painted over the other. So 
that finally, in the
expose routine that should copy the image to the display window, cairo crashes.

Perhaps we should debug this by consistently checking the status of all 
cairo surfaces
during the process. But with PNG pieces everything seems to work. So it 
looks like the
problem must occur in an early stage of converting SVG to a bitmap.

The routine in draw.c that does this is:

RsvgHandle *
LoadSVG (char *dir, int color, int piece)
{
  char buf[MSG_SIZ];
  RsvgHandle *svg=svgPieces[color][piece];
  RsvgDimensionData svg_dimensions;
  GError *svgerror=NULL;
  cairo_surface_t *img;
  cairo_t *cr;

  snprintf(buf, MSG_SIZ, "%s/%s%s.svg", dir, color ? "Black" : "White", 
pngPieceNames[piece]);
  if(svg || *dir && (svg = rsvg_handle_new_from_file(buf, &svgerror))) {
   rsvg_handle_get_dimensions(svg, &svg_dimensions);
    img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, squareSize, 
squareSize);
    cr = cairo_create(img);
    cairo_scale(cr, squareSize/(double) svg_dimensions.width, 
squareSize/(double) svg_dimensions.height);
    rsvg_handle_render_cairo(svg, cr);
    if(cairo_surface_status(img) == CAIRO_STATUS_SUCCESS) {
      if(pngPieceImages[color][piece]) 
cairo_surface_destroy(pngPieceImages[color][piece]);
      pngPieceImages[color][piece] = img;
    }
   cairo_destroy(cr);
    return svg;
  }
  if(svgerror) g_error_free(svgerror);
  return NULL;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.