[cairo] propsal for blur-API in cairo

Gerdus van Zyl gerdusvanzyl at gmail.com
Fri Jun 19 02:35:19 PDT 2009


Well the one use case is to blur the current path (after fill/stroke),
but that can be achieved by wrapping it in push/pop group and setting
the shader on the source, so it's only needed on the source surface.
Thus I change my suggestion to
cairo_source_add_shader(source,cairo_shader_params_struct);

Something that would be nice is to have a filter kernel/custom filter
as well, not just blurs. A blur is just a special case of a general
shader since it is used widely and specific algorithms are much faster
than generic kernel.
So my proposal was more of a general pixel shader api that could be
used to implement all rendering needed for SVG/flash/etc. using cairo
without having to have every possible filter in cairo.

> cairo_add_source_surface(...); // pushes *another* source onto the stack
> cairo_add_source_filter(CAIRL_MERGE_OVER...); // does "over" of the two on
Can't one composite sources already? (intermediate surface needed)

~G

On Fri, Jun 19, 2009 at 7:20 AM, Bill Spitzak<spitzak at gmail.com> wrote:
> Gerdus van Zyl wrote:
>>
>> see below how I imagine a filters api would look like. Note I'm not a
>> C coder so it's probably unrealistic,etc...
>
> Once again this proposal is to somehow blur everything that is drawn rather
> than just the contents of source surfaces.
>
> This is interesting but I believe may be far harder to implement, and may
> not be worth it if in fact users only want to blur the contents of a source
> image. An alternative is to add the blur to the source image, just like you
> can transform it, etc.
>
> As the arguments for the various blurs are completely different, I would
> prefer to see different calls for each of them, rather than a structure
> where only some of the fields are used depending on the blur.
>
> Possibly something like this to build an entire compositing tree:
>
> cairo_set_source_surface(...) // this resets all the filtering
> cairo_add_source_filter(CAIRO_BLUR, width, height);
> cairo_add_source_filter(...); // you can add multiple ones
> cairo_add_source_surface(...); // pushes *another* source onto the stack
> cairo_add_source_filter(CAIRL_MERGE_OVER...); // does "over" of the two on
> stack
>
>


More information about the cairo mailing list