Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::Filters::Filter Class Referencefinal

#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
 

Detailed Description

Definition at line 30 of file nr-filter.h.

Constructor & Destructor Documentation

◆ Filter() [1/2]

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().

◆ Filter() [2/2]

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.

Member Function Documentation

◆ _common_init()

◆ _filter_resolution()

std::pair< double, double > Inkscape::Filters::Filter::_filter_resolution ( Geom::Rect const &  area,
Geom::Affine const &  trans,
FilterQuality  q 
) const
private

◆ _resolution_limit()

◆ add_primitive()

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.

◆ area_enlarge()

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.

◆ clear_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.

◆ complexity()

double Inkscape::Filters::Filter::complexity ( Geom::Affine const &  ctm) const

Definition at line 283 of file nr-filter.cpp.

References primitives.

◆ filter_effect_area()

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().

◆ render()

int Inkscape::Filters::Filter::render ( Inkscape::DrawingItem const *  item,
DrawingContext graphic,
DrawingContext bgdc,
RenderContext rc 
) const

◆ reset_region()

void Inkscape::Filters::Filter::reset_region ( )

Resets the filter effects region to its default value as defined in SVG standard.

◆ reset_resolution()

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.

References _x_pixels, and _y_pixels.

◆ set_filter_units()

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.

◆ set_height()

void Inkscape::Filters::Filter::set_height ( SVGLength const &  length)

Definition at line 328 of file nr-filter.cpp.

References _region_height.

◆ set_output()

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.

◆ set_primitive_units()

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.

◆ set_region()

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.

◆ set_resolution() [1/2]

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.

References _x_pixels, and _y_pixels.

◆ set_resolution() [2/2]

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.

References _x_pixels, and _y_pixels.

◆ set_width()

void Inkscape::Filters::Filter::set_width ( SVGLength const &  length)

Definition at line 322 of file nr-filter.cpp.

References _region_width.

◆ set_x()

void Inkscape::Filters::Filter::set_x ( SVGLength const &  length)

Definition at line 310 of file nr-filter.cpp.

References _region_x.

◆ set_y()

void Inkscape::Filters::Filter::set_y ( SVGLength const &  length)

Definition at line 316 of file nr-filter.cpp.

References _region_y.

◆ update()

void Inkscape::Filters::Filter::update ( )

Update any embedded DrawingItems prior to rendering.

Definition at line 92 of file nr-filter.cpp.

References primitives.

◆ uses_background()

bool Inkscape::Filters::Filter::uses_background ( ) const

Definition at line 295 of file nr-filter.cpp.

References primitives.

Member Data Documentation

◆ _filter_units

SPFilterUnits Inkscape::Filters::Filter::_filter_units
private

Definition at line 185 of file nr-filter.h.

Referenced by _common_init(), filter_effect_area(), render(), and set_filter_units().

◆ _output_slot

int Inkscape::Filters::Filter::_output_slot
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().

◆ _primitive_units

SPFilterUnits Inkscape::Filters::Filter::_primitive_units
private

Definition at line 186 of file nr-filter.h.

Referenced by _common_init(), render(), and set_primitive_units().

◆ _region_height

SVGLength Inkscape::Filters::Filter::_region_height
private

Definition at line 177 of file nr-filter.h.

Referenced by _common_init(), filter_effect_area(), and set_height().

◆ _region_width

SVGLength Inkscape::Filters::Filter::_region_width
private

Definition at line 176 of file nr-filter.h.

Referenced by _common_init(), filter_effect_area(), and set_width().

◆ _region_x

SVGLength Inkscape::Filters::Filter::_region_x
private

Definition at line 174 of file nr-filter.h.

Referenced by _common_init(), filter_effect_area(), and set_x().

◆ _region_y

SVGLength Inkscape::Filters::Filter::_region_y
private

Definition at line 175 of file nr-filter.h.

Referenced by _common_init(), filter_effect_area(), and set_y().

◆ _slot_count

int Inkscape::Filters::Filter::_slot_count
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().

◆ _x_pixels

double Inkscape::Filters::Filter::_x_pixels
private

◆ _y_pixels

double Inkscape::Filters::Filter::_y_pixels
private

◆ primitives

std::vector<std::unique_ptr<FilterPrimitive> > Inkscape::Filters::Filter::primitives
private

The documentation for this class was generated from the following files: