[cairo] PDF Backend for cairo

Kristian Høgsberg krh at bitplanet.net
Tue Nov 30 21:51:16 PST 2004


Ross McFarland wrote:
> On Tue, 2004-11-30 at 22:10, Kristian Høgsberg wrote:
> 
>>Ross McFarland wrote:
>>...
>>
>>>pretty much the conclusion i came to. i got bogged down and spent
>>>several sessions trying to fix the transparency/tessilation problems and
>>>never got around to doing anything else with my backend.
>>
>>What kind of problems did you run into, more specifically?
> 
> http://www.neces.com/cairo/basket.pdf
> take a look at that file in a pdf viewer that supports alpha. the
> problem is the boundaries between tessilated traps. they overlaps ever
> so slightly and since that leaves two regions of the same color that are
> some amount transparent they add up to more of that color than should
> be. different pdf viewers seemed to have slightly different overlaps so
> i don't think this is something that can be fixed in cairo or the
> backend. to me this is why the route your proposed (passing the draw
> commands through to the backend) is probably the only real solution,
> anything else and you're going to run into things like this.

I took a look at your example PDF and found a couple of issues:  you're 
filling and stroking each trapezoid (the 'b' operator) which is wrong, 
all stroking is done by higher level cairo functionality, the PDF 
backend should only fill the trapezoids.  Second, a more subtle issue: 
you're filling each trapezoid separately, which cause them to be 
composited onto the backdrop separately.  I did the same thing 
originally, but now I draw one big path with each trapezoid as a closed 
subpath, and at the end I fill it all.  I guess, in the mathematical PDF 
model this doesn't make a difference, but when rendering with e.g. 
Render, it allows the rasterization process to ADD all the trapezoids 
into the mask before compositing, thus avoiding cracks.

If you zoom in on the artifacts:

   http://people.redhat.com/krh/cairo-pdf/basket-artifact.png

you can see the dark lines caused by the stroking. If you look even 
closer, you can see that there's a 1 pixel slightly lighter line in the 
middle of the dark line caused by the separate compositing.

I have the same example here:

   http://people.redhat.com/krh/cairo-pdf/basket.pdf

which renders quite nicely in acroread (with and without geometry anti 
aliasing enabled) and gpdf.  So I actually think it's possible to let 
cairo do the tessellation and still get nice results.  Even so, I still 
think it will be interesting to evaluate PDF level tessellation.

I did notice that your PDF loads in ggv, though, which the PDFs I 
produce don't.  I'm guessing I have an offset wrong or something, but I 
haven't yet been able to find it.

cheers,
Kristian



More information about the cairo mailing list