Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
nr-filter-merge.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * feMerge filter effect renderer
4 *
5 * Authors:
6 * Niko Kiirala <niko@kiirala.com>
7 *
8 * Copyright (C) 2007 authors
9 *
10 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11 */
12
13#include <vector>
14#include "display/cairo-utils.h"
18
19namespace Inkscape {
20namespace Filters {
21
24
26{
27 if (_input_image.empty()) return;
28
30 slot.set_primitive_area(_output, vp); // Needed for tiling
31
32 // output is RGBA if at least one input is RGBA
33 bool rgba32 = false;
34 cairo_surface_t *out = nullptr;
35 for (auto &i : _input_image) {
36 cairo_surface_t *in = slot.getcairo(i);
37 if (cairo_surface_get_content(in) == CAIRO_CONTENT_COLOR_ALPHA) {
40 rgba32 = true;
41 break;
42 }
43 }
44
45 if (!rgba32) {
47 }
48 cairo_t *out_ct = cairo_create(out);
49
50 for (auto &i : _input_image) {
51 cairo_surface_t *in = slot.getcairo(i);
52
54 cairo_set_source_surface(out_ct, in, 0, 0);
55 cairo_paint(out_ct);
56 }
57
58 cairo_destroy(out_ct);
59 slot.set(_output, out);
60 cairo_surface_destroy(out);
61}
62
64{
65 // Merge is a per-pixel primitive and is immutable under transformations
66 return true;
67}
68
70{
71 return 1.02;
72}
73
75{
76 for (int input : _input_image) {
78 return true;
79 }
80 }
81 return false;
82}
83
85{
86 _input_image[0] = slot;
87}
88
89void FilterMerge::set_input(int input, int slot)
90{
91 if (input < 0) return;
92
93 if (_input_image.size() > input) {
94 _input_image[input] = slot;
95 } else {
96 for (int i = _input_image.size(); i < input ; i++) {
98 }
99 _input_image.push_back(slot);
100 }
101}
102
103} // namespace Filters
104} // namespace Inkscape
105
106/*
107 Local Variables:
108 mode:c++
109 c-file-style:"stroustrup"
110 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
111 indent-tabs-mode:nil
112 fill-column:99
113 End:
114*/
115// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
cairo_surface_t * ink_cairo_surface_create_identical(cairo_surface_t *s)
Create a surface that differs only in pixel content.
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.
Definition affine.h:70
Axis aligned, non-empty rectangle.
Definition rect.h:92
bool can_handle_affine(Geom::Affine const &) const override
Indicate whether the filter primitive can handle the given affine.
bool uses_background() const override
void render_cairo(FilterSlot &) const override
double complexity(Geom::Affine const &ctm) const override
void set_input(int input) override
Sets the input slot number 'slot' to be used as input in rendering filter primitive 'primitive' For f...
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.
Definition of functions needed by several filters.
struct _cairo cairo_t
Definition path-cairo.h:16