Inkscape
Vector Graphics Editor
|
#include <nr-filter.h>
Public Member Functions | |
void | update () |
Update any embedded DrawingItems prior to rendering. | |
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, modify the contents of the surface backing graphic to represent the results of filter rendering. | |
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 | set_output (int slot) |
Sets the slot number 'slot' to be used as result from this filter. | |
void | set_x (SVGLength const &length) |
void | set_y (SVGLength const &length) |
void | set_width (SVGLength const &length) |
void | set_height (SVGLength const &length) |
void | set_region (SVGLength const &x, SVGLength const &y, SVGLength const &width, SVGLength const &height) |
Sets the filter effects region. | |
void | reset_region () |
Resets the filter effects region to its default value as defined in SVG standard. | |
void | set_resolution (double x_pixels) |
Sets the width of intermediate images in pixels. | |
void | set_resolution (double x_pixels, double y_pixels) |
Sets the width and height of intermediate images in pixels. | |
void | reset_resolution () |
Resets the filter resolution to its default value, i.e. | |
void | set_filter_units (SPFilterUnits unit) |
Set the filterUnits-property. | |
void | set_primitive_units (SPFilterUnits unit) |
Set the primitiveUnits-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. | |
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 |
bool | uses_background () const |
Filter () | |
Creates a new filter with space for one filter element. | |
Filter (int n) | |
Creates a new filter with space for n filter elements. | |
Private Member Functions | |
void | _common_init () |
std::pair< double, double > | _filter_resolution (Geom::Rect const &area, Geom::Affine const &trans, FilterQuality q) const |
Static Private Member Functions | |
static int | _resolution_limit (FilterQuality quality) |
Private Attributes | |
std::vector< std::unique_ptr< FilterPrimitive > > | primitives |
int | _slot_count |
Amount of image slots used when this filter was rendered last time. | |
int | _output_slot |
Image slot from which filter output should be read. | |
SVGLength | _region_x |
SVGLength | _region_y |
SVGLength | _region_width |
SVGLength | _region_height |
double | _x_pixels |
double | _y_pixels |
SPFilterUnits | _filter_units |
SPFilterUnits | _primitive_units |
Definition at line 30 of file nr-filter.h.
Inkscape::Filters::Filter::Filter | ( | ) |
Creates a new filter with space for one filter element.
Definition at line 58 of file nr-filter.cpp.
References _common_init().
Inkscape::Filters::Filter::Filter | ( | int | n | ) |
Creates a new filter with space for n filter elements.
If number of filter elements is known beforehand, it's better to use this constructor.
Definition at line 63 of file nr-filter.cpp.
References _common_init(), and primitives.
|
private |
Definition at line 69 of file nr-filter.cpp.
References _filter_units, _output_slot, _primitive_units, _region_height, _region_width, _region_x, _region_y, _slot_count, _x_pixels, _y_pixels, Inkscape::Filters::NR_FILTER_SLOT_NOT_SET, SVGLength::PERCENT, SVGLength::set(), SP_FILTER_UNITS_OBJECTBOUNDINGBOX, and SP_FILTER_UNITS_USERSPACEONUSE.
|
private |
Definition at line 373 of file nr-filter.cpp.
References _resolution_limit(), _x_pixels, _y_pixels, limit, Geom::GenericRect< C >::max(), and Geom::GenericRect< C >::min().
Referenced by render().
|
staticprivate |
Definition at line 356 of file nr-filter.cpp.
References Inkscape::Filters::FILTER_QUALITY_BEST, Inkscape::Filters::FILTER_QUALITY_BETTER, Inkscape::Filters::FILTER_QUALITY_NORMAL, Inkscape::Filters::FILTER_QUALITY_WORSE, and Inkscape::Filters::FILTER_QUALITY_WORST.
Referenced by _filter_resolution().
void Inkscape::Filters::Filter::add_primitive | ( | std::unique_ptr< FilterPrimitive > | primitive | ) |
Creates a new filter primitive under this filter object.
New primitive is placed so that it will be executed after all filter primitives defined beforehand for this filter object. Should this filter not have enough space for a new primitive, the filter is enlarged to accommodate the new filter element. It may be enlarged by more that one element. Returns a handle (non-negative integer) to the filter primitive created. Returns -1 if type is not a valid filter primitive type or a filter primitive of such type cannot be created.
Definition at line 173 of file nr-filter.cpp.
References primitives.
void Inkscape::Filters::Filter::area_enlarge | ( | Geom::IntRect & | area, |
Inkscape::DrawingItem const * | item | ||
) | const |
Modifies the given area to accommodate for filters needing pixels outside the rendered area.
When this function returns, area contains the area that needs to be rendered so that after filtering, the original area is drawn correctly.
Definition at line 188 of file nr-filter.cpp.
References item, and primitives.
void Inkscape::Filters::Filter::clear_primitives | ( | ) |
Removes all filter primitives from this filter.
All pointers to filter primitives inside this filter should be considered invalid after calling this function.
Definition at line 305 of file nr-filter.cpp.
References primitives.
double Inkscape::Filters::Filter::complexity | ( | Geom::Affine const & | ctm | ) | const |
Definition at line 283 of file nr-filter.cpp.
References primitives.
Geom::OptRect Inkscape::Filters::Filter::filter_effect_area | ( | Geom::OptRect const & | bbox | ) | const |
Returns the filter effects area in user coordinate system.
The given bounding box should be a bounding box as specified in SVG standard and in user coordinate system.
Definition at line 226 of file nr-filter.cpp.
References _filter_units, _region_height, _region_width, _region_x, _region_y, SVGLength::computed, SVGLength::PERCENT, scale, SP_FILTER_UNITS_OBJECTBOUNDINGBOX, SP_FILTER_UNITS_USERSPACEONUSE, and SVGLength::unit.
Referenced by render().
int Inkscape::Filters::Filter::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, modify the contents of the surface backing graphic to represent the results of filter rendering.
bgarea and area specify bounding boxes of both surfaces in world coordinates; Cairo contexts are assumed to be in default state (0,0 = surface origin, no path, OVER operator)
Definition at line 99 of file nr-filter.cpp.
References _filter_resolution(), _filter_units, _output_slot, _primitive_units, _x_pixels, filter_effect_area(), Inkscape::Filters::FilterUnits::get_matrix_display2pb(), item, Geom::GenericRect< C >::min(), origin, Inkscape::DrawingContext::paint(), primitives, rc, result, Inkscape::Filters::FilterUnits::set_automatic_resolution(), set_cairo_surface_ci(), Inkscape::Filters::FilterUnits::set_ctm(), Inkscape::Filters::FilterUnits::set_filter_area(), Inkscape::Filters::FilterUnits::set_item_bbox(), Inkscape::Filters::FilterUnits::set_paraller(), Inkscape::Filters::FilterUnits::set_resolution(), Inkscape::DrawingContext::setOperator(), Inkscape::DrawingContext::setSource(), SP_CSS_COLOR_INTERPOLATION_SRGB, Inkscape::DrawingContext::targetLogicalBounds(), Geom::X, and Geom::Y.
void Inkscape::Filters::Filter::reset_region | ( | ) |
Resets the filter effects region to its default value as defined in SVG standard.
void Inkscape::Filters::Filter::reset_resolution | ( | ) |
Resets the filter resolution to its default value, i.e.
automatically determined.
Definition at line 350 of file nr-filter.cpp.
void Inkscape::Filters::Filter::set_filter_units | ( | SPFilterUnits | unit | ) |
Set the filterUnits-property.
If not set, the default value of objectBoundingBox is used. If the parameter value is not a valid enumeration value from SPFilterUnits, no changes to filter state are made.
Definition at line 178 of file nr-filter.cpp.
References _filter_units.
void Inkscape::Filters::Filter::set_height | ( | SVGLength const & | length | ) |
Definition at line 328 of file nr-filter.cpp.
References _region_height.
void Inkscape::Filters::Filter::set_output | ( | int | slot | ) |
Sets the slot number 'slot' to be used as result from this filter.
If output is not set, the output from last filter primitive is used as output from the filter. It is an error to specify a pre-defined slot as 'slot'. Such call does not have any effect to the state of filter or its primitives.
void Inkscape::Filters::Filter::set_primitive_units | ( | SPFilterUnits | unit | ) |
Set the primitiveUnits-property.
If not set, the default value of userSpaceOnUse is used. If the parameter value is not a valid enumeration value from SPFilterUnits, no changes to filter state are made.
Definition at line 183 of file nr-filter.cpp.
References _primitive_units.
void Inkscape::Filters::Filter::set_region | ( | SVGLength const & | x, |
SVGLength const & | y, | ||
SVGLength const & | width, | ||
SVGLength const & | height | ||
) |
Sets the filter effects region.
Passing an unset length (length._set == false) as any of the parameters results in that parameter not being changed. Filter will not hold any references to the passed SVGLength object after function returns. If any of these parameters does not get set, the default value for that parameter as defined in the SVG standard is used instead.
void Inkscape::Filters::Filter::set_resolution | ( | double | x_pixels | ) |
Sets the width of intermediate images in pixels.
If not set, suitable resolution is determined automatically. If x_pixels is less than zero, calling this function results in no changes to filter state.
Definition at line 334 of file nr-filter.cpp.
void Inkscape::Filters::Filter::set_resolution | ( | double | x_pixels, |
double | y_pixels | ||
) |
Sets the width and height of intermediate images in pixels.
If not set, suitable resolution is determined automatically. If either parameter is less than zero, calling this function results in no changes to filter state.
Definition at line 342 of file nr-filter.cpp.
void Inkscape::Filters::Filter::set_width | ( | SVGLength const & | length | ) |
Definition at line 322 of file nr-filter.cpp.
References _region_width.
void Inkscape::Filters::Filter::set_x | ( | SVGLength const & | length | ) |
Definition at line 310 of file nr-filter.cpp.
References _region_x.
void Inkscape::Filters::Filter::set_y | ( | SVGLength const & | length | ) |
Definition at line 316 of file nr-filter.cpp.
References _region_y.
void Inkscape::Filters::Filter::update | ( | ) |
Update any embedded DrawingItems prior to rendering.
Definition at line 92 of file nr-filter.cpp.
References primitives.
bool Inkscape::Filters::Filter::uses_background | ( | ) | const |
Definition at line 295 of file nr-filter.cpp.
References primitives.
|
private |
Definition at line 185 of file nr-filter.h.
Referenced by _common_init(), filter_effect_area(), render(), and set_filter_units().
|
private |
Image slot from which filter output should be read.
Negative values mean 'not set'
Definition at line 172 of file nr-filter.h.
Referenced by _common_init(), and render().
|
private |
Definition at line 186 of file nr-filter.h.
Referenced by _common_init(), render(), and set_primitive_units().
|
private |
Definition at line 177 of file nr-filter.h.
Referenced by _common_init(), filter_effect_area(), and set_height().
|
private |
Definition at line 176 of file nr-filter.h.
Referenced by _common_init(), filter_effect_area(), and set_width().
|
private |
Definition at line 174 of file nr-filter.h.
Referenced by _common_init(), filter_effect_area(), and set_x().
|
private |
Definition at line 175 of file nr-filter.h.
Referenced by _common_init(), filter_effect_area(), and set_y().
|
private |
Amount of image slots used when this filter was rendered last time.
Definition at line 168 of file nr-filter.h.
Referenced by _common_init().
|
private |
Definition at line 182 of file nr-filter.h.
Referenced by _common_init(), _filter_resolution(), render(), reset_resolution(), set_resolution(), and set_resolution().
|
private |
Definition at line 183 of file nr-filter.h.
Referenced by _common_init(), _filter_resolution(), reset_resolution(), set_resolution(), and set_resolution().
|
private |
Definition at line 165 of file nr-filter.h.
Referenced by add_primitive(), area_enlarge(), clear_primitives(), complexity(), Filter(), render(), update(), and uses_background().