[librsvg: 8/31] Pass the NormalizeParams for filter functions directly from DrawingCtx
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 8/31] Pass the NormalizeParams for filter functions directly from DrawingCtx
- Date: Thu, 3 Jun 2021 02:27:10 +0000 (UTC)
commit 552a34a1eb365e7fb8909e4f0ac777fa036ae49f
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Jun 2 15:52:21 2021 -0500
Pass the NormalizeParams for filter functions directly from DrawingCtx
This lets us finally remove the use of ComputedValues from the filters code.
src/drawing_ctx.rs | 9 ++++++++-
src/filter.rs | 5 ++---
src/filter_func.rs | 10 +---------
3 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index e06f3554..a0ca2a3e 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -886,9 +886,16 @@ impl DrawingCtx {
if let Ok(specs) = filter_list
.iter()
.map(|filter_value| {
+ // Filter functions (like "blend()", not the <filter> element)
+ // require being resolved in userSpaceonUse units, since that is
+ // the default for primitive_units. So, get the corresponding
+ // NormalizeParams here and pass them down.
+ let view_params = self.push_coord_units(CoordUnits::UserSpaceOnUse);
+ let user_space_params = NormalizeParams::new(values, &view_params);
+
filter_value.to_filter_spec(
acquired_nodes,
- values,
+ &user_space_params,
current_color,
self,
node_name,
diff --git a/src/filter.rs b/src/filter.rs
index 960649de..a4ea4eb0 100644
--- a/src/filter.rs
+++ b/src/filter.rs
@@ -14,7 +14,6 @@ use crate::filters::{extract_filter_from_filter_node, FilterResolveError, Filter
use crate::length::*;
use crate::node::NodeBorrow;
use crate::parsers::{Parse, ParseValue};
-use crate::properties::ComputedValues;
use crate::rect::Rect;
use crate::xml::Attributes;
@@ -113,7 +112,7 @@ impl FilterValue {
pub fn to_filter_spec(
&self,
acquired_nodes: &mut AcquiredNodes<'_>,
- values: &ComputedValues,
+ user_space_params: &NormalizeParams,
current_color: RGBA,
draw_ctx: &DrawingCtx,
node_being_filtered_name: &str,
@@ -126,7 +125,7 @@ impl FilterValue {
node_being_filtered_name,
),
- FilterValue::Function(ref func) => func.to_filter_spec(values, current_color, draw_ctx),
+ FilterValue::Function(ref func) => func.to_filter_spec(user_space_params, current_color),
}
}
}
diff --git a/src/filter_func.rs b/src/filter_func.rs
index e434d120..5b63f5c9 100644
--- a/src/filter_func.rs
+++ b/src/filter_func.rs
@@ -17,8 +17,6 @@
use cssparser::{Color, Parser, RGBA};
use crate::angle::Angle;
-use crate::coord_units::CoordUnits;
-use crate::drawing_ctx::DrawingCtx;
use crate::error::*;
use crate::filter::Filter;
use crate::filters::{
@@ -34,7 +32,6 @@ use crate::filters::{
use crate::length::*;
use crate::paint_server::resolve_color;
use crate::parsers::{CustomIdent, NumberOrPercentage, Parse};
-use crate::properties::ComputedValues;
use crate::unit_interval::UnitInterval;
/// CSS Filter functions from the Filter Effects Module Level 1
@@ -644,14 +641,9 @@ impl FilterFunction {
#[allow(clippy::unnecessary_wraps)]
pub fn to_filter_spec(
&self,
- values: &ComputedValues,
+ params: &NormalizeParams,
current_color: RGBA,
- draw_ctx: &DrawingCtx,
) -> Result<FilterSpec, FilterResolveError> {
- // userSpaceonUse is the default for primitive_units
- let view_params = draw_ctx.push_coord_units(CoordUnits::UserSpaceOnUse);
- let params = NormalizeParams::new(values, &view_params);
-
match self {
FilterFunction::Blur(v) => Ok(v.to_filter_spec(¶ms)),
FilterFunction::Brightness(v) => Ok(v.to_filter_spec(¶ms)),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]