Fwd: [cairo] [PATCH] PDF: alpha-gradients; reused patterns;
cairo_paint_with_alpha
Kristian Høgsberg
krh at bitplanet.net
Thu Jul 27 20:03:49 PDT 2006
---------- Forwarded message ----------
From: Kristian Høgsberg <krh at bitplanet.net>
Date: Jul 25, 2006 3:10 PM
Subject: Re: [cairo] [PATCH] PDF: alpha-gradients; reused patterns;
cairo_paint_with_alpha
To: Miklós Erdélyi <erdelyim at gmail.com>
On 7/25/06, Miklós Erdélyi <erdelyim at gmail.com> wrote:
> On 7/25/06, Kristian Høgsberg <krh at bitplanet.net> wrote:
> > From a brief look-through, this looks like good work. I don't think
> > that the hashing is the best way to go, though. We've discussed
> > keeping a surface serial number that is bumped by the core cairo code
> > everytime the contents of a surface changes. This way you can just
> > remember the surface pointer and the serial number for the version
> > emitted in the PDF. If you see the same surface again and the
> > sequence number hasn't changed, just use the previously emitted
> > version. Plus it's usable by other backends who will want to do
> > similar things (PS and SVG at least). The hashing is less intrusive,
> > of course, but the sequence counter is useful enough that it belongs
> > in cairo core code.
> I knew about this, but for Inkscape users I wanted to make a complete
> patch to use for the Cairo-pdf export extension. Of course it's better
> to handle surface generation numbers at a higher level but since they
> hasn't been implemented yet I did this hashing thing in place of the
> serial+pointer thing.
> Regarding the pattern reuse code: when outputting text from Inkscape
> the printing engine spits text out in little chunks, sometimes two
> words in three go, and the gradient used to fill the text would be
> emitted three times if the pattern weren't reused completely. So this
> feature is really needed for printing with Inkscape. How should be
> this feature tweaked to be acceptable as a patch?[not including the
> reuse of surface_patterns with hashes of course] Later I could just
> hash the pointer and serial of the surface instead of the acquired
> source image from it and store the pointer and this would simply work
> with the current framework.
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.
> > Also, is it possible to split the patch into a couple of smaller
> > patches? At least the smask gradient work should be possible to
> > seperate from the pattern reuse code.
> Ok, I will make a separate patch for the separated
> stroking/non-stroking operators+alpha gradient stuff, plus one patch
> for the paint_with_alpha (I plan to implement full masking support
> later with an augmented operator set also) and leave out the
> surface_pattern reuse code because of the above. I need to include the
> use_pattern/use_gstate stuff in the first patch because otherwise
> gradients won't work so I hope there's no problem with that. Can I
> keep the interpolation function's reuse code in the smask gradient
> patch? It would be really useful because it reduces the mess in the
> output a lot.
Sure, just split it to the extent that it's feasible and makes sense.
> 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'm going to make these two patches today if possible but let me know
> if there's any problem with them or the way I would like to separate
> the bigger patch into smaller ones is not adequate in terms of feature
> content.
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.
cheers,
Kristian
More information about the cairo
mailing list