Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
nr-filter.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef INKSCAPE_DISPLAY_NR_FILTER_H
3#define INKSCAPE_DISPLAY_NR_FILTER_H
4
5/*
6 * SVG filters rendering
7 *
8 * Author:
9 * Niko Kiirala <niko@kiirala.com>
10 *
11 * Copyright (C) 2006 Niko Kiirala
12 *
13 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
14 */
15
16#include <memory>
17#include <cairo.h>
20#include "svg/svg-length.h"
22
23namespace Inkscape {
24class DrawingContext;
25class DrawingItem;
26class RenderContext;
27
28namespace Filters {
29
30class Filter final
31{
32public:
34 void update();
35
42
54 void add_primitive(std::unique_ptr<FilterPrimitive> primitive);
55
61 void clear_primitives();
62
70 void set_output(int slot);
71
72 void set_x(SVGLength const &length);
73 void set_y(SVGLength const &length);
74 void set_width(SVGLength const &length);
75 void set_height(SVGLength const &length);
76
86 void set_region(SVGLength const &x, SVGLength const &y,
87 SVGLength const &width, SVGLength const &height);
88
94
100 void set_resolution(double x_pixels);
101
108 void set_resolution(double x_pixels, double y_pixels);
109
114 void reset_resolution();
115
123
131
139 void area_enlarge(Geom::IntRect &area, Inkscape::DrawingItem const *item) const;
140
147
148 // returns cache score factor
149 double complexity(Geom::Affine const &ctm) const;
150
151 // says whether the filter accesses any of the background images
152 bool uses_background() const;
153
155 Filter();
156
162 Filter(int n);
163
164private:
165 std::vector<std::unique_ptr<FilterPrimitive>> primitives;
166
169
173
178
179 /* x- and y-resolutions for filter rendering.
180 * Negative values mean 'not set'.
181 * If _y_pixels is set, _x_pixels should be set too. */
182 double _x_pixels;
183 double _y_pixels;
184
187
188 void _common_init();
189 static int _resolution_limit(FilterQuality quality);
190 std::pair<double, double> _filter_resolution(Geom::Rect const &area,
191 Geom::Affine const &trans,
192 FilterQuality q) const;
193};
194
195} // namespace Filters
196} // namespace Inkscape
197
198#endif // INKSCAPE_DISPLAY_NR_FILTER_H
199/*
200 Local Variables:
201 mode:c++
202 c-file-style:"stroustrup"
203 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
204 indent-tabs-mode:nil
205 fill-column:99
206 End:
207*/
208// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
3x3 matrix representing an affine transformation.
Definition affine.h:70
Axis aligned, non-empty, generic rectangle.
Axis-aligned rectangle that can be empty.
Definition rect.h:203
Axis aligned, non-empty rectangle.
Definition rect.h:92
Minimal wrapper over Cairo.
SVG drawing item for display.
void set_x(SVGLength const &length)
void reset_resolution()
Resets the filter resolution to its default value, i.e.
std::vector< std::unique_ptr< FilterPrimitive > > primitives
Definition nr-filter.h:165
static int _resolution_limit(FilterQuality quality)
void set_height(SVGLength const &length)
Filter()
Creates a new filter with space for one filter element.
Definition nr-filter.cpp:58
void set_y(SVGLength const &length)
std::pair< double, double > _filter_resolution(Geom::Rect const &area, Geom::Affine const &trans, FilterQuality q) const
void update()
Update any embedded DrawingItems prior to rendering.
Definition nr-filter.cpp:92
void set_region(SVGLength const &x, SVGLength const &y, SVGLength const &width, SVGLength const &height)
Sets the filter effects region.
int render(Inkscape::DrawingItem const *item, DrawingContext &graphic, DrawingContext *bgdc, RenderContext &rc) const
Given background state from bgdc and an intermediate rendering from the surface backing graphic,...
Definition nr-filter.cpp:99
void set_filter_units(SPFilterUnits unit)
Set the filterUnits-property.
void area_enlarge(Geom::IntRect &area, Inkscape::DrawingItem const *item) const
Modifies the given area to accommodate for filters needing pixels outside the rendered area.
void set_primitive_units(SPFilterUnits unit)
Set the primitiveUnits-property.
void add_primitive(std::unique_ptr< FilterPrimitive > primitive)
Creates a new filter primitive under this filter object.
void clear_primitives()
Removes all filter primitives from this filter.
void reset_region()
Resets the filter effects region to its default value as defined in SVG standard.
SPFilterUnits _filter_units
Definition nr-filter.h:185
SPFilterUnits _primitive_units
Definition nr-filter.h:186
void set_resolution(double x_pixels)
Sets the width of intermediate images in pixels.
void set_output(int slot)
Sets the slot number 'slot' to be used as result from this filter.
int _output_slot
Image slot from which filter output should be read.
Definition nr-filter.h:172
Geom::OptRect filter_effect_area(Geom::OptRect const &bbox) const
Returns the filter effects area in user coordinate system.
double complexity(Geom::Affine const &ctm) const
void set_width(SVGLength const &length)
int _slot_count
Amount of image slots used when this filter was rendered last time.
Definition nr-filter.h:168
SVG length type.
Definition svg-length.h:22
RectangularCluster rc
SPItem * item
Helper class to stream background task notifications as a series of messages.
TODO: insert short description here.
TODO: insert short description here.
SPFilterUnits
double height
double width