pub struct FilterContext {
plan: Rc<FilterPlan>,
source_surface: SharedImageSurface,
last_result: Option<FilterOutput>,
previous_results: HashMap<CustomIdent, FilterOutput>,
primitive_units: CoordUnits,
effects_region: Rect,
_affine: Transform,
paffine: Transform,
}Expand description
Context for rendering a single crate::filters::FilterSpec.
Rendering a crate::filters::FilterSpec involves keeping track of possibly-named results
for each filter primitive (e.g. those that have an output attribute). This struct
maintains that information, plus all the extra data used during filtering.
Fields§
§plan: Rc<FilterPlan>Immutable values used during the execution of a filter property.
source_surface: SharedImageSurfaceThe source graphic surface.
last_result: Option<FilterOutput>Output of the last filter primitive.
previous_results: HashMap<CustomIdent, FilterOutput>Surfaces of the previous filter primitives by name.
primitive_units: CoordUnitsPrimtive units
effects_region: RectThe filter effects region.
_affine: TransformThe filter element affine matrix.
If filterUnits == userSpaceOnUse, equal to the drawing context matrix, so, for example,
if the target node is in a group with transform="translate(30, 20)", this will be equal
to a matrix that translates to 30, 20 (and does not scale). Note that the target node
bounding box isn’t included in the computations in this case.
If filterUnits == objectBoundingBox, equal to the target node bounding box matrix
multiplied by the drawing context matrix, so, for example, if the target node is in a group
with transform="translate(30, 20)" and also has x="1", y="1", width="50", height="50",
this will be equal to a matrix that translates to 31, 21 and scales to 50, 50.
This is to be used in conjunction with setting the viewbox size to account for the scaling.
For filterUnits == userSpaceOnUse, the viewbox will have the actual resolution size, and
for filterUnits == objectBoundingBox, the viewbox will have the size of 1, 1.
paffine: TransformThe filter primitive affine matrix.
See the comments for _affine, they largely apply here.
Implementations§
Source§impl FilterContext
impl FilterContext
Sourcepub fn new(
filter: &UserSpaceFilter,
plan: Rc<FilterPlan>,
source_surface: SharedImageSurface,
node_bbox: BoundingBox,
) -> Result<Self, FilterError>
pub fn new( filter: &UserSpaceFilter, plan: Rc<FilterPlan>, source_surface: SharedImageSurface, node_bbox: BoundingBox, ) -> Result<Self, FilterError>
Creates a new FilterContext.
pub fn session(&self) -> &Session
Sourcepub fn source_graphic(&self) -> &SharedImageSurface
pub fn source_graphic(&self) -> &SharedImageSurface
Returns the surface corresponding to the source graphic.
Sourcefn background_image(&self) -> SharedImageSurface
fn background_image(&self) -> SharedImageSurface
Returns the surface corresponding to the background image snapshot.
Sourcefn stroke_paint_image(&self) -> SharedImageSurface
fn stroke_paint_image(&self) -> SharedImageSurface
Returns a surface filled with the current stroke’s paint, for StrokePaint inputs in primitives.
Filter Effects 1: https://www.w3.org/TR/filter-effects/#attr-valuedef-in-strokepaint
Sourcefn fill_paint_image(&self) -> SharedImageSurface
fn fill_paint_image(&self) -> SharedImageSurface
Returns a surface filled with the current fill’s paint, for FillPaint inputs in primitives.
Filter Effects 1: https://www.w3.org/TR/filter-effects/#attr-valuedef-in-fillpaint
Sourcepub fn into_output(self) -> Result<SharedImageSurface, Error>
pub fn into_output(self) -> Result<SharedImageSurface, Error>
Converts this FilterContext into the surface corresponding to the output of the filter
chain.
The returned surface is in the sRGB color space.
Sourcepub fn store_result(&mut self, result: FilterResult)
pub fn store_result(&mut self, result: FilterResult)
Stores a filter primitive result into the context.
Sourcepub fn primitive_units(&self) -> CoordUnits
pub fn primitive_units(&self) -> CoordUnits
Returns the primitive units.
Sourcepub fn effects_region(&self) -> Rect
pub fn effects_region(&self) -> Rect
Returns the filter effects region.
Sourcefn get_unspecified_input(&self) -> FilterInput
fn get_unspecified_input(&self) -> FilterInput
Get a filter primitive’s default input as if its in=\"...\" were not specified.
Per https://drafts.fxtf.org/filter-effects/#element-attrdef-filter-primitive-in, “References to non-existent results will be treated as if no result was specified”. That is, fall back to the last result in the filter chain, or if this is the first in the chain, just use SourceGraphic.
Sourcefn get_input_raw(&self, in_: &Input) -> Result<FilterInput, FilterError>
fn get_input_raw(&self, in_: &Input) -> Result<FilterInput, FilterError>
Retrieves the filter input surface according to the SVG rules.
Sourcepub fn get_input(
&self,
in_: &Input,
color_interpolation_filters: ColorInterpolationFilters,
) -> Result<FilterInput, FilterError>
pub fn get_input( &self, in_: &Input, color_interpolation_filters: ColorInterpolationFilters, ) -> Result<FilterInput, FilterError>
Retrieves the filter input surface according to the SVG rules.
The surface will be converted to the color space specified by color_interpolation_filters.
Auto Trait Implementations§
impl Freeze for FilterContext
impl RefUnwindSafe for FilterContext
impl !Send for FilterContext
impl !Sync for FilterContext
impl Unpin for FilterContext
impl UnwindSafe for FilterContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.