[cairo] Flash features

Benjamin Otte otte at gnome.org
Fri Aug 31 13:16:55 PDT 2007

So, I've started looking at implementing the missing graphical
features needed for Flash 8 support in Swfdec. My goal is to have an
API and an initial image-based implementation ready for Cairo 1.6.

What did I do up to now?
I set up my own Cairo [1] and Pixman [2] git repos for playing around
with the ideas. And I added a cairo16 branch to Swfdec [3] so I can
test the features.

After that I made Emmanuel's blend mode patch [4] apply to current
master of pixman and cairo and made it work. And I added the two
operators that are in Flash but not in SVG: Subtract and Invert.
I'm wondering if these 2 operators can be replaced by a filter. And if
they could, does it make sense to keep them or should using filters be
advocated instead?
Apart from this, and from the fact that I probably overlooked
something, I think this can go in. So if someone could merge it or
tear it apart?

What am I planning to do?
My current idea of how to best implement filters, after various
discussions on irc, reading the list and looking at X, pixman and
boring specs is to provide APIs like this:
  cairo_pattern_create_$filter (source_pattern, filter_args);
The current filters I'm focusing on are blur, convolve and color_matrix.
I'm not going into a discussion of why I chose this method, as this
has been discussed for quite sometimes here already. If someone wants
me to elaborate on this, please tell me, and I'll try to summarize it
as best as I can. :)

So this is the current state, what are my current issues?
I still know way too little about cairo internals. I've been using the
API for quite a while and quite extensively, but there's still quite
some things I don't know. I'm also not that fluent in most backends,
as I primarily care about X11 and images right now. So if anything I
say causes (or could cause) problems in particular in these areas,
please tell me.

An interesting thing that my patches do is implement the nesting of
patterns. So you can take any pattern, create a blur pattern from it,
then a color matrix pattern and then another blur.
This also throws up some interesting questions that I don't have a
real answer to yet:
- How do we treat pattern properties such as extend and in particular
the matrix?
It would make things a lot simpler implementation-wise if the code
just copied over those values to the new pattern and ignored them on
the default pattern. Of course that makes some features harder to
achieve for users of cairo (such as implementing the feConvolveMatrix
filter in SVG). Any opinions here?
- How hard is it to optimize rendering of nested patterns?
Currently most backends just do a switch (pattern->type) - style code
for rendering patterns. Could extending that to (deeply) nested
patterns cause problems in backends?

I'm also not sure where to implement the graphical operations required
to do these patterns. I guess they should end up in pixman, but the
current pixman (and in turn Xrender) API for filters does not cope at
all with this nested approach. (In current pixman, a convolution
filter can be set as a normal filter instead of
bilinear/nearest/gaussian filtering). So I guess the API would need to
be extended to cope with it. I'm not sure how, but so far I think the
best way would be to have a function something like this:
  pixman_image_t * pixman_image_apply_$filter (pixman_image_t *source,
           pixman_box16_t *rect);
Does that look sensible to the pixman hackers?

I guess that's all. I hope all the comments show up before I waster
hours trying to implement all this. ;)


[1] http://gitweb.freedesktop.org/?p=users/company/cairo.git;a=summary
[2] http://gitweb.freedesktop.org/?p=users/company/pixman.git;a=summary
[3] http://gitweb.freedesktop.org/?p=swfdec/swfdec.git;a=summary
[4] http://lists.freedesktop.org/archives/cairo/2007-January/009268.html

More information about the cairo mailing list