Example #1
0
void
Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags)
{
    if (_root) {
        _root->render(ct, area, flags);
    }

    if (colorMode() == COLORMODE_GRAYSCALE) {
        // apply grayscale filter on top of everything
        cairo_surface_t *input = ct.rawTarget();
        cairo_surface_t *out = ink_cairo_surface_create_identical(input);
        ink_cairo_surface_filter(input, out, _grayscale_colormatrix);
        Geom::Point origin = ct.targetLogicalBounds().min();
        ct.setSource(out, origin[Geom::X], origin[Geom::Y]);
        ct.setOperator(CAIRO_OPERATOR_SOURCE);
        ct.paint();
        ct.setOperator(CAIRO_OPERATOR_OVER);
    
        cairo_surface_destroy(out);
    }
}
Example #2
0
void set_cairo_blend_operator( DrawingContext &dc, unsigned blend_mode ) {

    // All of the blend modes are implemented in Cairo as of 1.10.
    // For a detailed description, see:
    // http://cairographics.org/operators/
    switch (blend_mode) {
    case SP_CSS_BLEND_MULTIPLY:
        dc.setOperator(CAIRO_OPERATOR_MULTIPLY);
        break;
    case SP_CSS_BLEND_SCREEN:
        dc.setOperator(CAIRO_OPERATOR_SCREEN);
        break;
    case SP_CSS_BLEND_DARKEN:
        dc.setOperator(CAIRO_OPERATOR_DARKEN);
        break;
    case SP_CSS_BLEND_LIGHTEN:
        dc.setOperator(CAIRO_OPERATOR_LIGHTEN);
        break;
    case SP_CSS_BLEND_OVERLAY:   
        dc.setOperator(CAIRO_OPERATOR_OVERLAY);
        break;
    case SP_CSS_BLEND_COLORDODGE:
        dc.setOperator(CAIRO_OPERATOR_COLOR_DODGE);
        break;
    case SP_CSS_BLEND_COLORBURN:
        dc.setOperator(CAIRO_OPERATOR_COLOR_BURN);
        break;
    case SP_CSS_BLEND_HARDLIGHT:
        dc.setOperator(CAIRO_OPERATOR_HARD_LIGHT);
        break;
    case SP_CSS_BLEND_SOFTLIGHT:
        dc.setOperator(CAIRO_OPERATOR_SOFT_LIGHT);
        break;
    case SP_CSS_BLEND_DIFFERENCE:
        dc.setOperator(CAIRO_OPERATOR_DIFFERENCE);
        break;
    case SP_CSS_BLEND_EXCLUSION:
        dc.setOperator(CAIRO_OPERATOR_EXCLUSION);
        break;
    case SP_CSS_BLEND_HUE:       
        dc.setOperator(CAIRO_OPERATOR_HSL_HUE);
        break;
    case SP_CSS_BLEND_SATURATION:
        dc.setOperator(CAIRO_OPERATOR_HSL_SATURATION);
        break;
    case SP_CSS_BLEND_COLOR:
        dc.setOperator(CAIRO_OPERATOR_HSL_COLOR);
        break;
    case SP_CSS_BLEND_LUMINOSITY:
        dc.setOperator(CAIRO_OPERATOR_HSL_LUMINOSITY);
        break;
    case SP_CSS_BLEND_NORMAL:
    default:
        dc.setOperator(CAIRO_OPERATOR_OVER);
        break;
    }
}