[cairo] Knockout groups in cairo-pdf fallbacks make poppler emit more fallbacks in cairo-ps

Carl Worth cworth at cworth.org
Thu May 22 07:50:53 PDT 2008

[Poppler folks, I'm just bringing you into this discussion mid-thread.
The context for the first two paragraphs is that I just made a bug fix
in cairo to prevent fallback images inside groups get rendered at
72dpi instead of the desired 300 or 600dpi or whatever. Following
those paragraphs is a description of a new bug that involves
interactions of cairo and poppler and cairo again.]

On Wed, 21 May 2008 15:54:03 -0700, Carl Worth wrote:
> (There's only a single, low-resolution fallback image in the
> original firefox-triggered bug I'm chasing down.)

And that bug isn't entirely fixed by my earlier changes either. Yes,
the fallback image now ends up at the correct resolution, but parts of
the original HTML file, (a table and an image), now don't appear at

From investigating, it appears that the PDF file created by firefox
contains a knockout group. From the comments in cairo-pdf-surface.c
this is expected for any page with fallback images, (though why this
simple page with just some text, a table, and an image is resulting in
any fallback image is not clear to me---so that's something to chase
down still).

Next, poppler goes through quite a lot of pain to correctly render a
knockout group. It renders everything in the group twice, (once to
compute the group and once to compute its "shape"---that is an alpha
mask representing the outline of any objects---but not any
transparency of those objects). Finally, poppler manually composites
the shape and group with DEST_OUT and ADD, (apparently trying to do
something simpler than SOURCE).

It's these DEST_OUT and ADD operations that are forcing additional
fallbacks when poppler/cairo renders the final result to PostScript.

But all we wanted from the original fallback image, (and the purpose
for the knockout group), is simply to paint it without any alpha
blending. And that should be the simplest of all operations in
PostScript---simply a single 'image' operation which can't do alpha
blending by definition.

So, given the following chain:

	application -> cairo-pdf -> poppler -> cairo-ps

We need to make sure that a fallback in the original PDF results in
something simple like an 'image' operation in the final PostScript
file, and not ever-larger fallback images as is currently happening.

This will require care in cairo-pdf, some changes in poppler, and care
in cairo-ps as well.

I'll follow up with a simple HTML file that can be used with firefox3
to demonstrate the problem throughout the chain, (I'll post the files
from each stage as well).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080522/fd9e6cec/attachment.pgp 

More information about the cairo mailing list