Struct rsvg::filters::context::FilterContext
source · pub struct FilterContext {
stroke_paint: Rc<UserSpacePaintSource>,
fill_paint: Rc<UserSpacePaintSource>,
source_surface: SharedImageSurface,
last_result: Option<FilterOutput>,
previous_results: HashMap<CustomIdent, FilterOutput>,
background_surface: OnceCell<Result<SharedImageSurface, FilterError>>,
stroke_paint_surface: OnceCell<Result<SharedImageSurface, FilterError>>,
fill_paint_surface: OnceCell<Result<SharedImageSurface, FilterError>>,
primitive_units: CoordUnits,
effects_region: Rect,
_affine: Transform,
paffine: Transform,
}
Expand description
The filter rendering context.
Fields§
§stroke_paint: Rc<UserSpacePaintSource>
Paint source for primitives which have an input value equal to StrokePaint
.
fill_paint: Rc<UserSpacePaintSource>
Paint source for primitives which have an input value equal to FillPaint
.
source_surface: SharedImageSurface
The 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.
background_surface: OnceCell<Result<SharedImageSurface, FilterError>>
Input surface for primitives that require an input of BackgroundImage
or BackgroundAlpha
. Computed lazily.
stroke_paint_surface: OnceCell<Result<SharedImageSurface, FilterError>>
§fill_paint_surface: OnceCell<Result<SharedImageSurface, FilterError>>
§primitive_units: CoordUnits
Primtive units
effects_region: Rect
The filter effects region.
_affine: Transform
The 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: Transform
The filter primitive affine matrix.
See the comments for _affine
, they largely apply here.
Implementations§
source§impl FilterContext
impl FilterContext
sourcepub fn new(
filter: &UserSpaceFilter,
stroke_paint: Rc<UserSpacePaintSource>,
fill_paint: Rc<UserSpacePaintSource>,
source_surface: &SharedImageSurface,
draw_transform: Transform,
node_bbox: BoundingBox,
) -> Result<Self, FilterError>
pub fn new( filter: &UserSpaceFilter, stroke_paint: Rc<UserSpacePaintSource>, fill_paint: Rc<UserSpacePaintSource>, source_surface: &SharedImageSurface, draw_transform: Transform, node_bbox: BoundingBox, ) -> Result<Self, FilterError>
Creates a new FilterContext
.
sourcepub fn source_graphic(&self) -> &SharedImageSurface
pub fn source_graphic(&self) -> &SharedImageSurface
Returns the surface corresponding to the source graphic.
sourcefn background_image(
&self,
draw_ctx: &DrawingCtx,
) -> Result<SharedImageSurface, FilterError>
fn background_image( &self, draw_ctx: &DrawingCtx, ) -> Result<SharedImageSurface, FilterError>
Returns the surface corresponding to the background image snapshot.
sourcefn stroke_paint_image(
&self,
acquired_nodes: &mut AcquiredNodes<'_>,
draw_ctx: &mut DrawingCtx,
) -> Result<SharedImageSurface, FilterError>
fn stroke_paint_image( &self, acquired_nodes: &mut AcquiredNodes<'_>, draw_ctx: &mut DrawingCtx, ) -> Result<SharedImageSurface, FilterError>
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,
acquired_nodes: &mut AcquiredNodes<'_>,
draw_ctx: &mut DrawingCtx,
) -> Result<SharedImageSurface, FilterError>
fn fill_paint_image( &self, acquired_nodes: &mut AcquiredNodes<'_>, draw_ctx: &mut DrawingCtx, ) -> Result<SharedImageSurface, FilterError>
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,
acquired_nodes: &mut AcquiredNodes<'_>,
draw_ctx: &mut DrawingCtx,
in_: &Input,
) -> Result<FilterInput, FilterError>
fn get_input_raw( &self, acquired_nodes: &mut AcquiredNodes<'_>, draw_ctx: &mut DrawingCtx, in_: &Input, ) -> Result<FilterInput, FilterError>
Retrieves the filter input surface according to the SVG rules.
sourcepub fn get_input(
&self,
acquired_nodes: &mut AcquiredNodes<'_>,
draw_ctx: &mut DrawingCtx,
in_: &Input,
color_interpolation_filters: ColorInterpolationFilters,
) -> Result<FilterInput, FilterError>
pub fn get_input( &self, acquired_nodes: &mut AcquiredNodes<'_>, draw_ctx: &mut DrawingCtx, 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.