[librsvg/attribute-parsers-737: 19/26] FilterContext: extract method to find a primitive's default input
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/attribute-parsers-737: 19/26] FilterContext: extract method to find a primitive's default input
- Date: Fri, 21 Oct 2022 01:06:08 +0000 (UTC)
commit 7b39b4ae2e2905c4ff51c63512079ee7c4f02c05
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Oct 20 18:19:24 2022 -0500
FilterContext: extract method to find a primitive's default input
src/filters/context.rs | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/src/filters/context.rs b/src/filters/context.rs
index 47ae32afb..17a746f80 100644
--- a/src/filters/context.rs
+++ b/src/filters/context.rs
@@ -280,6 +280,20 @@ impl FilterContext {
self.effects_region
}
+ /// 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.
+ fn get_unspecified_input(&self) -> FilterInput {
+ if let Some(output) = self.last_result.as_ref() {
+ FilterInput::PrimitiveOutput(output.clone())
+ } else {
+ FilterInput::StandardInput(self.source_graphic().clone())
+ }
+ }
+
/// Retrieves the filter input surface according to the SVG rules.
fn get_input_raw(
&self,
@@ -288,16 +302,7 @@ impl FilterContext {
in_: &Input,
) -> Result<FilterInput, FilterError> {
match *in_ {
- Input::Unspecified => {
- // No value => use the last result.
- // As per the SVG spec, if the filter primitive is the first in the chain, return the
- // source graphic.
- if let Some(output) = self.last_result.as_ref() {
- Ok(FilterInput::PrimitiveOutput(output.clone()))
- } else {
- Ok(FilterInput::StandardInput(self.source_graphic().clone()))
- }
- }
+ Input::Unspecified => Ok(self.get_unspecified_input()),
Input::SourceGraphic => Ok(FilterInput::StandardInput(self.source_graphic().clone())),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]