masking-path-07-b - Clip path with union of clipped paths is not handled properly
In the master branch, there is ignore-masking-path-07-b.svg
from the SVG 1.1 test suite; it is ignored because that test does not currently pass. It has this:
<clipPath id="clipCircle1">
<circle id="c1" cx="100" cy="100" r="50"/>
</clipPath>
<clipPath id="clipCircle2">
<circle id="c2" cx="150" cy="150" r="50"/>
</clipPath>
<clipPath id="clipPath1">
<path id="p1" d="M10 10l100 0 0 100 -100 0ZM50 50l40 0 0 40 -40 0Z" clip-rule="evenodd"/>
</clipPath>
<clipPath id="clipInClip1">
<use xlink:href="#c2" clip-path="url(#clipCircle1)"/>
<use xlink:href="#p1"/>
</clipPath>
<rect width="200" height="200" fill="blue" clip-path="url(#clipInClip1)"/>
The clipInClip1
clip path is union(intersection(circlc2, circle1), path1)
, but it gets computed incorrectly. This is because when we enter a clipping context, Cairo is only able to shrink the current clip path via cairo_clip()
- it cannot do the union between the clipped c2
and p1
.
I think we need to handle clip paths as masks: rasterize each element inside a clipPath
as an alpha mask, then take their union, and use the result as the whole clipPath
.
Edited by Federico Mena Quintero