[cairo] color matrix filter in cairo and pixman
Henry (Yu) Song - SISA
hsong at sisa.samsung.com
Thu Jul 12 08:00:45 PDT 2012
Hi, All
Continuing what is left off. I have prototyped GL backend for Gaussian, convolution and color matrix. It is working for msaa compositor - you need msaa-capable driver and set env CAIRO_GL_COMPOSITOR=msaa. Gaussian filter is using two-passes for now. This means we have to first paint into a temp surface for the first pass and then paint back to the target surface with second pass. It is OK for large image, however, for small image, this is inefficient - it is better to do it in one pass, because the overhead of switching FBO. I will do it later once fix GL spans/traps compositor.
Thanks
Henry
-----Original Message-----
From: Henry (Yu) Song - SISA
Sent: Friday, June 29, 2012 6:00 PM
To: cairo at cairographics.org
Subject: color matrix filter in cairo and pixman
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
More information about the cairo
mailing list