[cairo] Best strategy for complex screen drawing
Bill Spitzak
spitzak at d2.com
Mon Nov 28 14:39:03 PST 2005
Timothée Lecomte wrote:
> http://tipote.free.fr/wxt16.png
>
> (to compare with desired output : http://tipote.free.fr/wxt15.png )
>
> Any idea to workaround it ?
I'm beginning to think that, despite it's appeal, the current approach
to antialiasing is not going to work for real-world applications, such
as the one being shown in these sample images.
The solution with current Cairo is: SATURATE will kind of work, but
requires a seperate buffer. If the figure overlaps itself you will have
to draw each overlapping layer seperately, you need to split it whenever
the visible side of the polygon changes, splitting "bowtie" ones into
two triangles. I think there may be problems if you try to texture-map
your surface with any kind of transparency, but I am not sure.
Because of the difficulty in figuring out how to use SATURATE and set up
a second buffer, and the fact that it cannot be used in many cases, I am
afraid that most programs will give up and turn off antialiasing. This
means that cairo output is not going to look very good.
I really feel that the solution is to add "aliased_lineto" to the
path-construction operators. This acts exactly like lineto except if the
path is filled (or used in a filled way, such as a clipping path) then
no antialiasing is done to that straight edge.
If the example program then used aliased_lineto for each internal edge
of the polygon, and regular lineto for the outer 1 or 2 edges of the
polygons at the edge, and drew from back to front, using OVER in the
main image buffer, would draw mostly correctly, perhaps good enough for
what you want.
To get it perfect, the edges where it curls over so you face the other
side must be detected and draw antialiased. This is not as hard as the
work needed for SATURATE, as you can draw the polygons on each side in
any order, rather than having to defer all the ones that face one
direction until the next layer. You also have to split "bowtie" polygons
into two triangles.
More information about the cairo
mailing list