[cairo] Polygon clipping problem

cu cairouser at yahoo.com
Thu Feb 12 13:26:58 PST 2009

I seem to be having an issue with clipping large polygons when surface
size is small relative to them.

Here is a simple test I am using:
 surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 500, 500);

   //cairo_surface_set_device_offset(surf, (-1. * x1 / 2.), y1 / 2.);
   //cairo_surface_set_device_offset(surf, 0, -500.);

   cr = cairo_create(surf);

   cairo_move_to(cr, x1, y1);
   cairo_line_to(cr, -1. * x1, y1);
   cairo_line_to(cr, -1. * x1, -1. * y1);
   cairo_line_to(cr, x1, -1. * y1);
   cairo_set_source_rgb(cr, 1., 0., 0.);


   cairo_surface_write_to_png(surf, "test.png");

When values of x1 and/or y1 are over specific limit (setting one of the
two values to 40000000 does the trick), the surface is not properly
filled. Instead, it either has a narrow filled band or is empty (if one
of the device_offset functions is uncommented). As values decrease
towards about 35M progressively more of the surface would be filled.

Is this an expected behavior? It would seem that although large, the
numbers are not near the limit of even 32 bit integer (and certainly not



More information about the cairo mailing list