[cairo] propsal for blur-API in cairo
Gerdus van Zyl
gerdusvanzyl at gmail.com
Thu Jun 18 10:39:58 PDT 2009
see below how I imagine a filters api would look like. Note I'm not a
C coder so it's probably unrealistic,etc.
enum cairo_filter_type
{
CAIRO_FILTER_BLUR_BOX,
CAIRO_FILTER_BLUR_GAUSSIAN,
CAIRO_FILTER_KERNEL,
CAIRO_FILTER_CUSTOM
};
struct cairo_filter_params {
cairo_filter_type shader_type,
int radius, //for blur types
kerneltype kernel, //for kernel
int kernelwidth,
int kernelheight,
functioncallback pixelmangler, //custom filter c implementation
type pixelmangler_shader //custom filter GLSL shader implementation
}
//main function
cairo_shader(ctx,cairo_filter_params);
cairo_shader_preserve
//convenience functions
cairo_blur_box(ctx,2);
cairo_blur_box_preserve
cairo_blur_gaussian(ctx,2);
//so to draw a rectangle on a blurred background would be:
cairo_blur_box(ctx,2);
cairo_rectangle(ctx,10,10,20,20);
cairo_fill(ctx);
//to draw a blurred rectangle on a non blurred background
cairo_rectangle(ctx,10,10,20,20);
cairo_fill_preserve(ctx);
cairo_blur_box(ctx,2);
//more than 1 filter
cairo_rectangle(ctx,10,10,20,20);
cairo_fill_preserve(ctx);
cairo_blur_box_preserve(ctx,2);
cairo_shader(ctx,embosfilter of cairo_filter_params type);
So basically if there is a current path (_preserve) it only operates
on that construct otherwise it operates on the entire surface. This is
probably untenable :-)
~Gerdus
On Thu, Jun 18, 2009 at 5:09 AM, Vladimir Vukicevic<vladimir at pobox.com> wrote:
> On 6/17/09 1:23 PM, Mirco Müller wrote:
>> Greetings cairo-lovers!
>>
>> I've spent some time thinking of what an API-addition for blurring in
>> cairo should look like. I tried to stick to the pattern used by the API
>> used for gradients.
>>
>> The main idea is to introduce an opaque blur-object similar to a
>> gradient-pattern. You can set type and quality of it. Along those lines
>> also setters and getters for the numerous values controlling each
>> blur-type.
>
> Is the intent of this to introduce "blur" as a new backend operation, so
> that backends can accelerate blur as appropriate? If not, I'd suggest
> that this be part of the cairo-utils librarly that's been discussed for
> a while, and that would act on an input surface (perhaps via an exposed
> acquire/release api?)..
>
> - Vlad
>
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
More information about the cairo
mailing list