Current work within cairo uses knockout groups to render fine-grained image-based fallbacks for cairo operations that are not directly supported by PDF. When rendering these cairo files with poppler, it's clear that the knockout groups are not being handled correctly. I'll attach some simple examples to show the problem. -Carl
Created attachment 11295 [details] PDF file demonstrating bug (over-below-source) This file should show a vector, translucent green circle with an image of a traslucent, red triangle above it, but in a knockout group so that it completely obscures the circle. Expressed in cairo terms, the circle is rendered with the OVER operator, while the triangle is rendered with the SOURCE operator. Currently, poppler is blending the triangle with the circle, rather than obscuring the circle. I've verified that acroread renders the file as desired. I'll attach a couple of renderings to make things clear. -Carl
Created attachment 11296 [details] Buggy, poppler rendering of over-below-source
Created attachment 11297 [details] Desired rendering of over-below-source NOTE: This rendering contains translucence while the buggy rendering has been flattened against a white background. This difference is indicental. The bug I'm trying to demonstrate is the difference in the region of the image where the triangle and the circle overlap. Also, we should soon be pushing the necessary changes to cairo so that generating these images is as simple as "make check". Stay tuned. -Carl
Moving to general, splash seems to have the same problem.
(In reply to comment #3) > Also, we should soon be pushing the necessary changes to cairo so that > generating these images is as simple as "make check". Stay tuned. The support for fine-grained fallbacks in cairo PDF output has now been pushed out to cairo's master branch. However, the tests that exercise this bug have now been disabled in cairo's test suite. So to exercise this bug with cairo's test suite requires editing cairo/boilerplate/cairo-boilerplate-pdf.c and removing the desired test names from the pdf_ignored_tests list. The 7 affected tests are clip-operator, operator-clear, operator-source, over-above-source, over-around-source, over-below-source, and over-between-source. -Carl
Adding support for this to the cairo backend will require some work. Supporting knockout groups requires tracking shape and opacity seperately. The cairo backend currently implements transparency groups using cairo_push/pop_group, but these do not help with tracking shape. However, support should be possible by tracking shape with an additional CAIRO_CONTENT_ALPHA surface.
(In reply to comment #6) > Adding support for this to the cairo backend will require some work. Supporting > knockout groups requires tracking shape and opacity seperately. The cairo > backend currently implements transparency groups using cairo_push/pop_group, > but these do not help with tracking shape. However, support should be possible > by tracking shape with an additional CAIRO_CONTENT_ALPHA surface. I did try an experiment to implement something very much like the example in plate 17 of the PDF reference, (a 2x2 matrix showing the effects of knockout and isolated grouups). And yes, it will be a bit tricky to do that completely. I think it will require two passes over the group in some cases, as you suggest. But, for the limited use of knockout groups that cairo is currently emitting, you should be able to get by with something much simpler. For example, just drawing all objects within the group with CAIRO_OPERATOR_SOURCE should do the trick. It might indeed be very worthwhile to start with just that, and then later flesh out more complete support for all the combinations of knockout and isolated groups as required. Let me know if you have any more questions about that. -Carl
(In reply to comment #7) > (In reply to comment #6) > > Adding support for this to the cairo backend will require some work. Supporting > > knockout groups requires tracking shape and opacity seperately. The cairo > > backend currently implements transparency groups using cairo_push/pop_group, > > but these do not help with tracking shape. However, support should be possible > > by tracking shape with an additional CAIRO_CONTENT_ALPHA surface. > > I did try an experiment to implement something very much like the > example in plate 17 of the PDF reference, (a 2x2 matrix showing the > effects of knockout and isolated grouups). And yes, it will be a bit > tricky to do that completely. I think it will require two passes over > the group in some cases, as you suggest. > > But, for the limited use of knockout groups that cairo is currently > emitting, you should be able to get by with something much > simpler. For example, just drawing all objects within the group with > CAIRO_OPERATOR_SOURCE should do the trick. This falls apart as soon as you have a group inside the knock-out group. Which is what the pdf generated by cairo has. e.g. cairo_set_source_arg(0.8, 0, 0, 0.5); cairo_set_operator(SOURCE); draw_square(); draw_circle_in_square(); has a very different result (circle inside square) than cairo_set_source_arg(0.8, 0, 0, 0.5); cairo_set_operator(SOURCE); draw_square(); cairo_push_group(); draw_circle_in_square(); cairo_pop_group_to_source(); cairo_paint(); which paints a circle and clears the rest of the surface. (arguably not what you'd expect when using push/pop_group()). I have a very hacked up poppler tree that tries to do proper shape and opacity tracking. The output is currently 'correct' except it looks bad (seams) because of the lack of EXTEND_PAD. -Jeff
Should be fixed in git (for the cairo backend of course)
Reopening for the Splash backend
(In reply to comment #10) > Reopening for the Splash backend I had a look at it: in the current splash implementation the knockout for transparency groups was missing. Because it's the same area as Bug 13487 I'll fix it together with it in 0.22.0 (if Albert accepts it)
Created attachment 60310 [details] Here a small appetiser Produced with my current code. Unnecessary to say, that of course also the over-below-source PDF works now in splash
Created attachment 60600 [details] [review] Implementation of knockout groups in splash Ok, let's continue with this one. This should implement knockout groups in splash
It fixes the bug, but the letters in https://bugs.launchpad.net/ubuntu/+source/poppler/+bug/817626/+attachment/2238754/+files/512 pages SAMPLE.pdf get too much "punched" seems to me the old rendering is much closer (if not exact) to what Adode renders, any idea why?
Created attachment 60726 [details] [review] New implementation of knockout groups in splash In the way splash implements shape and antialiasing effects my first implementation also knockouts these effects. The new implementation is now much trickier and leave these effects untouched. Also the PDF file demonstrating this bug looks a little bit smarter with the new implementation, i.e. it looses now the white line between triangle. Your sample of comment 17 still has some but now very small, nearly unvisible changes.
Created attachment 60728 [details] [review] Correct patch Sorry, I uploaded not the patch but an intermediate state, Here the one I really regtested. BTW, in comment 15 I meant "white line between circle and triangle", and I want to point to the PDF of comment 14.
Fixed fox Splash too
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.