[cairo] gaussian filter and custom convolution filter

Henry (Yu) Song - SISA hsong at sisa.samsung.com
Tue Jun 26 09:13:55 PDT 2012

There has been several threads on how to design cairo APIs for blur and other filtering effects in the past, but no prototype implementation of ideas.

Since filtering effects are increasing becoming important and common in 2D graphics, such as SVG, CSS and 2D Canvas, I took the opportunity to propose few new APIs for filtering and implemented a prototype for them.  There are two new filterings in the proposal/prototype

1. Implemented CARO_FILTER_GAUSSIAN for image backend.   In addition to set filter type to CAIRO_FILTER_GAUSSIAN, I added few cairo APIs to allow set/get gaussian radius and sigma

2. Add a new cairo filter type - CAIRO_FILTER_CONVOLUTION.  This is intended to allow apps to specify their own convolution matrix. a new API (cairo_pattern_set_convolution_matrix()) is provided for this purpose.  An implementation for such custom filtering is also implemented for image backend.

I am aware that people have proposed chain-like APIs such that filtering effects can be chained together.  I thought to achieve such effect we can use multiple filter effects.

The actual implementation can be downloaded from git clone https://code.google.com/p/cairogles/ and then "git checkout release-filter".  Sample code, image and result image are also attached for your testing.  The underlying implementation for cairo gaussian filter and convolution filters uses pixman convolution filter.  The pixman convolution implementation is not optimized for gaussian, - would like to see/work on optimization for it.

Please review,  comments are extremely welcome.

Thanks a lot.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo_filter.c
Type: text/x-csrc
Size: 2637 bytes
Desc: cairo_filter.c
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120626/00403572/attachment-0001.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image008.png
Type: image/png
Size: 10009 bytes
Desc: image008.png
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120626/00403572/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: result.png
Type: image/png
Size: 57277 bytes
Desc: result.png
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120626/00403572/attachment-0003.png>

More information about the cairo mailing list