Comment 4 for bug 1417470

David R. Bild (drbild) wrote :

This issue with objects in groups/layers that have a mask, clip, or partial opacity applied. Those get rendered between the two two ends of a cairo_push_group() and a cairo_pop_group() pairing. We call cairo_show_page() to switch to a new page in the pdf, but a group is active, Cairo ignores the call and all the graphics end up on the same pdf page.

I must have never tested an SVG with clips, masks, or group-/layer-level opacity.

For a fix, ideally, a call to cairo_show_page() would render every thing in the current group(s) to the current page, then start a new page, but keep the group stack active (with its associated transforms). Subsequent items would go into the group (getting the same group transformations applied) and be rendered on to the new pdf page. But I don't think Cairo can function like that, without introducing many other bugs.

Instead, we should just not interleave text and graphics between a cairo_push_group()/cairo_pop_group() pair. All the graphics in that group should be rendered to one pdf page and all the text should be rendered on top of that page.

This method will properly interleave text/graphics for many images and not break others. Images with text inside of clipped/masked/partially opaque groups may be incorrect, but they were before as well.

I can successfully compile master again, so I'll try to get a patch for this prepared within the next 7-10 days.