There is allready support for Clip in SVG/Cairo, with problems: 1. If you have a clip with more than one path, GraphicsContextCairo makes a intersection instead of a union. http://svg.tutorial.aptico.de/grafik_svg/kap14_1.svg 2. Wrong transformation of skewX and skewY (could be more problems). http://apike.ca/prog_svg_clip.html 2. No animation-support for Clipping
Created attachment 20922 [details] Clipping in SVG/Cairo The first problem is caused by GraphicsContext. After each insertion of a path, the clip is created and directly drawn to cairo_t. This patch draw the clipping at the end of insertion of paths.
Created attachment 20956 [details] Fixed transformation This patch fixes transformation of paths (first point 2).
The second point 2 is a problem of animation and localization and affects any animation, not only clipping. If you use e.g. en_US it works, with de_DE or it_IT as language-setting it won't work (export LANG="de_DE.UTF-8").
Created attachment 21216 [details] Clipping in SVG/Cairo This patch corrects a bug in the previous patch and combines the fixes on clipping and path-transformation. Furthermore the code keeps with the Cg-implementation for a better code-reading.
Comment on attachment 21216 [details] Clipping in SVG/Cairo I'm not sure I understand the matrix changes for path. And why would you want to reset the clip every time you enter applyClip, even if there is no clip to apply? Seems like the early-return when there is no clip could be before the clip-reset.
Created attachment 21546 [details] Clipping in SVG/Cairo Made the matrix changes more effective (the inverting is still necessary) and moved cairo_clip_reset() behind the return.
Comment on attachment 21546 [details] Clipping in SVG/Cairo Looks fine.
Committed revision 34454.