[cairo] filters/image processing
cworth at cworth.org
Fri Mar 24 08:31:17 PST 2006
On Fri, 24 Mar 2006 10:23:31 -0500, MenTaLguY wrote:
> We've been discussing "Cairoification" in Inkscape recently again,
Sounds like fun!
> If we adopt Cairo, should we expect to always have to implement
> things like e.g. gaussian blur ourselves using intermediate image
> surfaces, or will Cairo eventually provide image processing
> operations like that in ways which can be accelerated in hardware?
We already have an API for specifying that a given filter should be
applied to a pattern, (cairo_pattern_set_filter), but the current
selection of filters is fairly limited here. So I see two things that
need to be done:
1) We need to add more filter types. Gaussian blur is an obvious first
one that needs to be added, and something I've been giving some
thought to lately. One trick with this is that it requires at least
one parameter, so the current cairo_filter_t enum is not going to
Oh, look, there is even a CAIRO_FILTER_GAUSSIAN there already. I'm
not sure if that does anything useful or not yet.
2) We need to add support for filtering the implicit masks that cairo
generates. This is the right place to put a filter for doing
something like a drop shadow or for applying what Xara calls
"feathering" to a filled shape.
There's still a mask pattern involved here, but the user doesn't
get to see it since it is implicitly created by cairo. So I think
all we need here is a simple new API:
cairo_set_mask_filter (cairo_t *cr, cairo_filter_t filter);
(Modulo the same enum limitations we discussed above.) So this
filter would be applied to the implicit masks created by
cairo_stroke, _fill, _show_text, and _show_glyphs. It would not
apply to cairo_mask where the user has a pointer to a pattern
already and can call cairo_pattern_set_filter.
As for what filter types to add, I think that "can be accelerated in
hardware" is a pretty good criterion for inclusion in cairo. I think
we've got Gaussian blur stuff just sitting there waiting in some
existing backends already.
As for a bunch of the other SVG filter types, I'm less confident that
we'll see a lot of hardware support for them. I don't think it makes
sense to complicate the cairo API for these if they're all going to
end up in software anyway. (Though, if someone can convince
programmable GPUs to do these, then there's a different question to be
asked---so let me know if you know someone that has figured that out.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060324/d356ea38/attachment.pgp
More information about the cairo