34struct ComposeArithmetic
36 ComposeArithmetic(
double k1,
double k2,
double k3,
double k4)
37 : _k1(round(k1 * 255))
38 , _k2(round(k2 * 255*255))
39 , _k3(round(k3 * 255*255))
40 , _k4(round(k4 * 255*255*255)) {}
44 EXTRACT_ARGB32(in1, aa, ra, ga, ba)
45 EXTRACT_ARGB32(in2, ab, rb, gb, bb)
47 gint32 ao = _k1*aa*ab + _k2*aa + _k3*ab + _k4;
48 gint32 ro = _k1*ra*rb + _k2*ra + _k3*rb + _k4;
49 gint32 go = _k1*ga*gb + _k2*ga + _k3*gb + _k4;
50 gint32 bo = _k1*ba*bb + _k2*ba + _k3*bb + _k4;
52 ao =
pxclamp(ao, 0, 255*255*255);
53 ro = (
pxclamp(ro, 0, ao) + (255*255/2)) / (255*255);
54 go = (
pxclamp(go, 0, ao) + (255*255/2)) / (255*255);
55 bo = (
pxclamp(bo, 0, ao) + (255*255/2)) / (255*255);
56 ao = (ao + (255*255/2)) / (255*255);
58 ASSEMBLE_ARGB32(pxout, ao, ro, go, bo)
87 cairo_t *ct = cairo_create(out);
88 cairo_set_source_surface(ct, input1, 0, 0);
91 cairo_set_operator(ct, CAIRO_OPERATOR_IN);
94 cairo_set_operator(ct, CAIRO_OPERATOR_OUT);
97 cairo_set_operator(ct, CAIRO_OPERATOR_ATOP);
100 cairo_set_operator(ct, CAIRO_OPERATOR_XOR);
103 cairo_set_operator(ct, CAIRO_OPERATOR_ADD);
116 cairo_surface_destroy(out);
131 if (input == 0)
_input = slot;
132 if (input == 1)
_input2 = slot;
146 if (!std::isfinite(
k1) || !std::isfinite(
k2) || !std::isfinite(
k3) || !std::isfinite(
k4)) {
147 g_warning(
"Non-finite parameter for feComposite arithmetic operator");
Cairo software blending templates.
G_GNUC_CONST gint32 pxclamp(gint32 v, gint32 low, gint32 high)
void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_surface_t *out, Blend &&blend)
Blend two surfaces using the supplied functor.
void ink_cairo_surface_blit(cairo_surface_t *src, cairo_surface_t *dest)
cairo_surface_t * ink_cairo_surface_create_output(cairo_surface_t *image, cairo_surface_t *bg)
void set_cairo_surface_ci(cairo_surface_t *surface, SPColorInterpolation ci)
Set the color_interpolation_value for a Cairo surface.
Cairo integration helpers.
3x3 matrix representing an affine transformation.
Axis aligned, non-empty rectangle.
double complexity(Geom::Affine const &ctm) const override
void set_arithmetic(double k1, double k2, double k3, double k4)
void set_input(int input) override
Sets the input slot number 'slot' to be used as input in rendering filter primitive 'primitive' For f...
~FilterComposite() override
bool can_handle_affine(Geom::Affine const &) const override
Indicate whether the filter primitive can handle the given affine.
void render_cairo(FilterSlot &) const override
void set_operator(FeCompositeOperator op)
SPColorInterpolation color_interpolation
Geom::Rect filter_primitive_area(FilterUnits const &units) const
Returns the filter primitive area in user coordinate system.
void set_primitive_area(int slot, Geom::Rect &area)
cairo_surface_t * getcairo(int slot)
Returns the pixblock in specified slot.
void set(int slot, cairo_surface_t *s)
Sets or re-sets the pixblock associated with given slot.
FilterUnits const & get_units() const
struct _cairo_surface cairo_surface_t
Helper class to stream background task notifications as a series of messages.