[cairo] separating compositing and blending

Adrian Johnson ajohnson at redneon.com
Sat Jan 5 23:26:12 PST 2013


On 21/10/12 02:09, Rik Cabanier wrote:
> All,
> 
> the current cairo compositing operators combine blending and compositing
> [1].
> This means that if you do an 'overlay', the result of the 'overlay'
> blending formula will always be composited with 'src-over'.
> 
> Nikos (from Canon) and I (from Adobe) have a proposed working draft
> that allows people to specify blending and compositing in CSS [2]. As
> an example, this would allow you to do a 'screen' blend on an HTML
> element with a 'src' compositing mode. This separation could also be
> extended to canvas.
> 
> Looking at the Cairo architecture, it seems that this could be added
> by adding an optional blend mode operator to 'set_operator'.
> What do people think?

We can't change the cairo_set_operator function since this would break
API compatibility. We could add a new function:

cairo_set_blend_mode (cairo_r *cr, cairo_blend_mode_t bm);

typedef enum {
    CAIRO_BLEND_MODE_NORMAL,
    CAIRO_BLEND_MODE_MULTIPLY,
    CAIRO_BLEND_MODE_SCREEN,
    CAIRO_BLEND_MODE_OVERLAY,
    CAIRO_BLEND_MODE_DARKEN,
    CAIRO_BLEND_MODE_LIGHTEN,
    CAIRO_BLEND_MODE_COLOR_DODGE,
    CAIRO_BLEND_MODE_COLOR_BURN,
    CAIRO_BLEND_MODE_HARD_LIGHT,
    CAIRO_BLEND_MODE_SOFT_LIGHT,
    CAIRO_BLEND_MODE_DIFFERENCE,
    CAIRO_BLEND_MODE_EXCLUSION,
    CAIRO_BLEND_MODE_HSL_HUE,
    CAIRO_BLEND_MODE_HSL_SATURATION,
    CAIRO_BLEND_MODE_HSL_COLOR,
    CAIRO_BLEND_MODE_HSL_LUMINOSITY
} cairo_blend_mode_t;

and specify that setting a blend mode (the enum range
CAIRO_OPERATOR_MULTIPLY..CAIRO_OPERATOR_HSL_LUMINOSITY) in
cairo_set_operator ignores the blend mode set by cairo_set_blend_mode
and always uses Normal.

> 
> Rik
> 
> 1: http://cairographics.org/operators/
> 2: https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html
> 3: http://cairographics.org/manual/cairo-cairo-t.html#cairo-set-operator
> 
> 



More information about the cairo mailing list