[cairo] Best strategy for complex screen drawing
timothee.lecomte at ens.fr
Sat Nov 26 05:52:32 PST 2005
Alexander Larsson wrote:
>On Fri, 2005-11-25 at 18:07 +0100, Timothée Lecomte wrote:
>> cairo_set_line_width(cr, 1);
>Why are you stroking each polygon? That is a pretty complicated
>operation and doesn't seem necessary for producing the kind of image you
>show in your screenshot.
>Maybe this is an issue with "seams" between the polygons?
>If so, you
>need to render all the polygons comprising the larger 3d surface using
>CAIRO_OPERATOR_ADD to a temporary cairo surface and then composite that
>to the real cairo surface (using CAIRO_OPERATOR_OVER, or whatever mode
>you currently use).
I have just tried this solution : I prepare an intermediate surface via :
cairo_surface_t *polygon_surface = cairo_surface_create_similar
polygon_cr = cairo_create (polygon_surface);
cairo_set_operator (polygon_cr, CAIRO_OPERATOR_ADD);
Then, I draw to it without stroking, and finally copy to the real
surface via :
cairo_set_source_surface (cr, polygon_surface, 0, 0);
It gives no seam, and it is much quicker (400 ms to draw the 10000
polygons on a generic image surface, instead of 1500 ms).
Unfortunately, there are some unwanted side effects, because I have to
draw polygons over already existing polygons, and with
CAIRO_OPERATOR_ADD this leads to some transparency effects. Here is a
(to compare with desired output : http://tipote.free.fr/wxt15.png )
Any idea to workaround it ?
Thanks for your help !
More information about the cairo