[librsvg: 5/27] ResolvedPrimitive.into_user_space - take a NormalizeParams
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 5/27] ResolvedPrimitive.into_user_space - take a NormalizeParams
- Date: Mon, 10 May 2021 16:06:42 +0000 (UTC)
commit d5a2dd2705b8ff80d94228af544cf2bf2fd23afe
Author: Federico Mena Quintero <federico gnome org>
Date: Fri May 7 19:37:42 2021 -0500
ResolvedPrimitive.into_user_space - take a NormalizeParams
src/filter_func.rs | 7 ++++---
src/filters/mod.rs | 28 +++++++++++-----------------
2 files changed, 15 insertions(+), 20 deletions(-)
---
diff --git a/src/filter_func.rs b/src/filter_func.rs
index 8039ba26..d1930958 100644
--- a/src/filter_func.rs
+++ b/src/filter_func.rs
@@ -63,8 +63,9 @@ impl Blur {
.map(|l| l.normalize(values, params))
.unwrap_or(0.0);
- let user_space_filter =
- Filter::default().to_user_space(&NormalizeParams::new(values, params));
+ let params = NormalizeParams::new(values, params);
+
+ let user_space_filter = Filter::default().to_user_space(¶ms);
let gaussian_blur = ResolvedPrimitive {
primitive: Primitive::default(),
@@ -73,7 +74,7 @@ impl Blur {
..GaussianBlur::default()
}),
}
- .into_user_space(values, params);
+ .into_user_space(¶ms);
FilterSpec {
user_space_filter,
diff --git a/src/filters/mod.rs b/src/filters/mod.rs
index 6dc885f7..802f4833 100644
--- a/src/filters/mod.rs
+++ b/src/filters/mod.rs
@@ -7,7 +7,7 @@ use std::time::Instant;
use crate::bbox::BoundingBox;
use crate::document::AcquiredNodes;
-use crate::drawing_ctx::{DrawingCtx, ViewParams};
+use crate::drawing_ctx::DrawingCtx;
use crate::element::{Draw, ElementResult, SetAttributes};
use crate::error::{ElementError, ParseError, RenderingError};
use crate::filter::UserSpaceFilter;
@@ -15,7 +15,6 @@ use crate::length::*;
use crate::node::{Node, NodeBorrow};
use crate::paint_server::UserSpacePaintSource;
use crate::parsers::{CustomIdent, Parse, ParseValue};
-use crate::properties::ComputedValues;
use crate::property_defs::ColorInterpolationFilters;
use crate::surface_utils::shared_surface::{SharedImageSurface, SurfaceType};
use crate::transform::Transform;
@@ -178,15 +177,11 @@ impl Parse for Input {
}
impl ResolvedPrimitive {
- pub fn into_user_space(
- self,
- values: &ComputedValues,
- params: &ViewParams,
- ) -> UserSpacePrimitive {
- let x = self.primitive.x.map(|l| l.normalize(values, ¶ms));
- let y = self.primitive.y.map(|l| l.normalize(values, ¶ms));
- let width = self.primitive.width.map(|l| l.normalize(values, ¶ms));
- let height = self.primitive.height.map(|l| l.normalize(values, ¶ms));
+ pub fn into_user_space(self, params: &NormalizeParams) -> UserSpacePrimitive {
+ let x = self.primitive.x.map(|l| l.to_user(params));
+ let y = self.primitive.y.map(|l| l.to_user(params));
+ let width = self.primitive.width.map(|l| l.to_user(params));
+ let height = self.primitive.height.map(|l| l.to_user(params));
UserSpacePrimitive {
x,
@@ -286,10 +281,12 @@ pub fn extract_filter_from_filter_node(
let elt = primitive_node.borrow_element();
let effect = elt.as_filter_effect().unwrap();
- let primitive_values = elt.get_computed_values();
-
let primitive_name = format!("{}", primitive_node);
+ let view_params = draw_ctx.push_coord_units(user_space_filter.primitive_units);
+ let primitive_values = elt.get_computed_values();
+ let params = NormalizeParams::new(&primitive_values, &view_params);
+
effect
.resolve(acquired_nodes, &primitive_node)
.map_err(|e| {
@@ -300,10 +297,7 @@ pub fn extract_filter_from_filter_node(
);
e
})
- .map(|primitive| {
- let params = draw_ctx.push_coord_units(user_space_filter.primitive_units);
- primitive.into_user_space(primitive_values, ¶ms)
- })
+ .map(|primitive| primitive.into_user_space(¶ms))
})
.collect::<Result<Vec<UserSpacePrimitive>, FilterResolveError>>()?;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]