[cairo] Polygon clipping problem

cu cairouser at yahoo.com
Sat Feb 14 12:13:43 PST 2009

Chris Wilson wrote:
> There are very few people crazy enough to tackle the tessellator --
> welcome!

Well, I realize that and, in all honesty, I am done with that attempt :)
It was fun but it took much time from my primary application and success
was far from guaranteed. I am not the greatest graphics specialist in
the world and I know where my limits lie :)

> Simply because the work has not been completed yet. In order for it to a
> make a difference whilst tessellating requires substantial changes to
> the data types -- which has been completed. However, the goal of that
> branch is to eliminate the artefacts due to self-intersecting polygons
> and before I push that, it must not cause severe performance
> regressions.

I did not really mean full-scale clipping of all polygons with each
other. Clipping to just the surface rectangle is not a very difficult
task. In fact, this is the solution I had to implement to avoid hitting
the fixed point limits.

I started by clipping only largest of polygons to the surface dimensions
before giving them to cairo to draw. This seemed to create a slight
speed up, so I went further and now clip all polygons that aren't
entirely contained in surface. There is a small but measurable speed up
from doing so (perhaps 10% for images with more polygons). This is
achieved with clipping function using double-precision numbers and
includes overhead time due to memory allocation/deallocation (specific
to my program, and certainly could be eliminated otherwise).

This also guarantees that no polygon given to cairo is significantly
larger than a surface in any direction - removing the need for
tessellator to work on large numbers.

Just mentioning.


More information about the cairo mailing list