[cairo] filling by way of clipping path

Cosmin Apreutesei cosmin.apreutesei at gmail.com
Wed Aug 1 09:14:54 PDT 2012


Hi guys,

I'm new to cairo and I'd like some feedback on an idea. I'm making a
DOM-like data structure for cairo which can be rendered on a surface
and should cover all of cairo's capabilities. This includes filling a
path with a "group object" which can itself contain other filled paths
and other groups. At first I implemented this by way of push_group();
draw-object...; pop_group_to_source(); draw-path...; fill(). But I
want to re-implement this using only clipping paths, that is: save();
draw-path...; clip(); draw-object...; restore(). I will choose this
strategy assuming 1) the drawing will be faster as cairo is smart
enough to avoid drawing outside the clipping path, and 2) a temporary
bitmap will not be created as with push_group(), so again faster and
less memory. Are these assumptions correct? Also, can there be
anything different in terms of screen results between the first and
the second strategy? In can't see any difference in my limited tests
but maybe I'm missing something.

[OT: anyone knows of a C lib that can do path union & intersection,
including paths with curves?]

Thanks,
Cosmin.


More information about the cairo mailing list