Fwd: [cairo] [PATCH] PDF: alpha-gradients; reused patterns; cairo_paint_with_alpha

Kristian Høgsberg krh at bitplanet.net
Thu Jul 27 20:04:44 PDT 2006


---------- Forwarded message ----------
From: Miklós Erdélyi <erdelyim at gmail.com>
Date: Jul 25, 2006 6:34 PM
Subject: Re: [cairo] [PATCH] PDF: alpha-gradients; reused patterns;
cairo_paint_with_alpha
To: Kristian Høgsberg <krh at bitplanet.net>


On 7/25/06, Kristian Høgsberg <krh at bitplanet.net> wrote:
> Pattern reuse is definitely useful, and hashing for this purpose is
> probably fine, but since you're already hashing the patterns, consider
> using cairo_hash_table_t.
I will give it a try. Please find the gradients+stroking/non-stroking
operators separated plus paint_with_alpha patch attached (they have to
be applied in the beforementioned order). I hope this can be now
committed. I haven't polluted the mailing list with these.

> > Also, when is it planned to add the surface serial stuff?
> It's just a matter of writing the patch ;)  It's probably less work
> than the hashing code you already did - add the serial number to
> cairo_surface_t, change each cairo-surface.c entry point to bump the
> number and you're done.  It's of course a cairo 1.4 thing at this
> point.
I might write this then :) How would you calculate the serial?
The problem with this approach is that it still doesn't handle
identical image_surfaces for example. Generating a checksum/hash for
the image data is required to reuse image patterns. A lot of space can
be saved with this for example when a company logo is displayed on
every page... If you draw it with native cairo then it won't be
repeated in the stream (because the same surface will be used). But
for example when exporting to PDF from Inkscape the images are always
recreated for cairo (though this might change when they'll move to a
Cairo-based renderer) so it would be emitted into the the stream every
time it's printed.

> Another concern is that we probably want a versioning system as for
> the SVG surface.  The smask feature was introduced in PDF 1.4 and many
> viewers don't yet support that.  The SVG surface has
> cairo_svg_surface_restrict_to_version() and related functions, and the
> PDF surface should use a similar mechanism.
This would make sense if the fallback images would be generated for
only the relevant part of the surface. Otherwise what could be done
with for example gradients? Maybe premultiplying the color stops with
alpha? Or just ignoring them? Or other wizardry?

Best regards,
miklos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gradients.patch
Type: text/x-patch
Size: 35971 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060727/7ca4dafe/gradients-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: paint_with_alpha.patch
Type: text/x-patch
Size: 4461 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060727/7ca4dafe/paint_with_alpha-0001.bin


More information about the cairo mailing list