[cairo] color matrix filter in cairo and pixman

Henry (Yu) Song - SISA hsong at sisa.samsung.com
Fri Jun 29 17:59:31 PDT 2012


Hi, All

Continuing previous of gaussian and convolution matrix,  I also add color matrix filter in cairo and pixman.  I thought pixman is the most efficient place to add such filtering

ColorMatrix filter should be fairly common in SVG, and right now canvas2D uses javascript for color filtering.  With this function implemented in cairo/pixman, we can do a better job in canvas 2D  In addition, implementing in pixman should be at least as fast as what is currently implemented in webkit.  If has clip, cairo/pixman is faster because it skips those pixels that are clipped out.  We will also implement such filters in GL backend.

You can download cairo from git clone https://code.google.com/p/cairogles/ and then "git checkout release-filter", also clone my pixman from git clone https://code.google.com/p/pixman-samsung/ and checkoiut "colormatrix" branch.  Attached are sample test code, source image and test result images for your testing.  Please review and comment.

Thanks in advance

Henry

________________________________________
From: Henry (Yu) Song - SISA
Sent: Tuesday, June 26, 2012 9:13 AM
To: cairo at cairographics.org
Subject: gaussian filter and custom convolution filter

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.

Henry
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo_filter.c
Type: text/x-csrc
Size: 4395 bytes
Desc: cairo_filter.c
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120630/80f992cc/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/20120630/80f992cc/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: result.png
Type: image/png
Size: 48780 bytes
Desc: result.png
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120630/80f992cc/attachment-0003.png>


More information about the cairo mailing list