[cairo] Improving PDF output

Carl Worth cworth at cworth.org
Mon Jan 8 13:17:25 PST 2007


On Mon, 08 Jan 2007 07:24:15 -0800, Carl Worth wrote:
> [*] Well, another hard part is the fact that most gradients trigger
> rasterization in PDF.

Oops. Make that _all_ gradients cause rasterization. See the following
implementation of _pattern_supported in cairo-pdf-surface.c:

	static cairo_bool_t
	_pattern_supported (cairo_pattern_t *pattern)
	{
	    if (pattern->type == CAIRO_PATTERN_TYPE_SOLID)
	        return TRUE;

	    if (pattern->type == CAIRO_PATTERN_TYPE_SURFACE)
	        return _surface_pattern_supported ((cairo_surface_pattern_t *)
	        pattern);

	    return FALSE;
	}

and note that it returns FALSE for gradient pattern types,
(CAIRO_PATTERN_TYPE_LINEAR and CAIRO_PATTERN_TYPE_RADIAL).

I disabled all the "native" PDF gradient code as it wasn't working in
all cases. A very first step would be for someone to characterize
which gradients would actually work with the current code, (2 color
stops? alpha == 1.0 for all stops?), and fix _pattern_supported to
advertise that properly.

The next step would be to take pieces one at a time from Miklós' patch [*]
and incorporate them along with corresponding tweaks to
_pattern_supported.

Even without looking at the test suite results, it's pretty clear that
Miklós patch isn't ready as is. For example, it changes
_pattern_supported to advertise that _all_ gradient patterns are
supported yet it maintains the following comment:

    /* FIXME: There is a difference between the cairo gradient extend
     * semantics and PDF extend semantics. PDFs extend=false means
     * that nothing is painted outside the gradient boundaries,
     * whereas cairo takes this to mean that the end color is padded
     * to infinity. Setting extend=true in PDF gives the cairo default
     * behavoir, not yet sure how to implement the cairo mirror and
     * repeat behaviour. */

We don't need to fix everything at once. We can do this in incremental
steps, but I don't want to introduce any regressions as we go, (we
might also need better coverage of gradients---for example, with the
various extend types), while doing this work.

[*] http://lists.freedesktop.org/archives/cairo/2006-August/007648.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070108/54684ab3/attachment.pgp


More information about the cairo mailing list