[librsvg: 7/23] feColorMatrix - resolve and render separately
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 7/23] feColorMatrix - resolve and render separately
- Date: Thu, 11 Mar 2021 23:12:24 +0000 (UTC)
commit aebc211058275da0bf508b9b0fdef342235ca569
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Mar 11 13:18:03 2021 -0600
feColorMatrix - resolve and render separately
src/filters/color_matrix.rs | 33 +++++++++++++++++++++++++--------
src/filters/mod.rs | 5 ++---
2 files changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/src/filters/color_matrix.rs b/src/filters/color_matrix.rs
index b318831f..c85283eb 100644
--- a/src/filters/color_matrix.rs
+++ b/src/filters/color_matrix.rs
@@ -8,6 +8,7 @@ use crate::element::{ElementResult, SetAttributes};
use crate::error::*;
use crate::node::{CascadedValues, Node};
use crate::parsers::{NumberList, NumberListLength, Parse, ParseValue};
+use crate::property_defs::ColorInterpolationFilters;
use crate::surface_utils::{
iterators::Pixels, shared_surface::ExclusiveImageSurface, ImageSurfaceDataExt, Pixel,
};
@@ -35,6 +36,14 @@ pub struct FeColorMatrix {
matrix: Matrix5<f64>,
}
+/// Resolved `feColorMatrix` primitive for rendering.
+pub struct ColorMatrix {
+ base: Primitive,
+ in1: Input,
+ matrix: Matrix5<f64>,
+ color_interpolation_filters: ColorInterpolationFilters,
+}
+
impl Default for FeColorMatrix {
/// Constructs a new `ColorMatrix` with empty properties.
#[inline]
@@ -139,19 +148,19 @@ impl SetAttributes for FeColorMatrix {
}
}
-impl FeColorMatrix {
+impl ColorMatrix {
pub fn render(
&self,
- node: &Node,
ctx: &FilterContext,
acquired_nodes: &mut AcquiredNodes<'_>,
draw_ctx: &mut DrawingCtx,
) -> Result<FilterResult, FilterError> {
- let cascaded = CascadedValues::new_from_node(node);
- let values = cascaded.get();
- let cif = values.color_interpolation_filters();
-
- let input_1 = ctx.get_input(acquired_nodes, draw_ctx, &self.in1, cif)?;
+ let input_1 = ctx.get_input(
+ acquired_nodes,
+ draw_ctx,
+ &self.in1,
+ self.color_interpolation_filters,
+ )?;
let bounds = self
.base
.get_bounds(ctx)?
@@ -209,7 +218,15 @@ impl FeColorMatrix {
impl FilterEffect for FeColorMatrix {
fn resolve(&self, node: &Node) -> Result<PrimitiveParams, FilterError> {
- Ok(PrimitiveParams::ColorMatrix(node.clone()))
+ let cascaded = CascadedValues::new_from_node(node);
+ let values = cascaded.get();
+
+ Ok(PrimitiveParams::ColorMatrix(ColorMatrix {
+ base: self.base.clone(),
+ in1: self.in1.clone(),
+ matrix: self.matrix.clone(),
+ color_interpolation_filters: values.color_interpolation_filters(),
+ }))
}
}
diff --git a/src/filters/mod.rs b/src/filters/mod.rs
index 4afd3b77..4803d26a 100644
--- a/src/filters/mod.rs
+++ b/src/filters/mod.rs
@@ -52,7 +52,6 @@ pub mod offset;
pub mod tile;
pub mod turbulence;
-use color_matrix::FeColorMatrix;
use component_transfer::FeComponentTransfer;
use composite::FeComposite;
use convolve_matrix::FeConvolveMatrix;
@@ -75,7 +74,7 @@ use turbulence::FeTurbulence;
/// `feMerge` gathers info from its `feMergNode` children).
pub enum PrimitiveParams {
Blend(blend::Blend),
- ColorMatrix(Node),
+ ColorMatrix(color_matrix::ColorMatrix),
ComponentTransfer(Node),
Composite(Node),
ConvolveMatrix(Node),
@@ -326,7 +325,7 @@ fn render_primitive(
match (elt, params) {
(Element::FeBlend(_), Blend(p)) => p.render(ctx, acquired_nodes, draw_ctx),
- (Element::FeColorMatrix(ref inner), ColorMatrix(node)) =>
FeColorMatrix::render(&inner.element_impl, &node, ctx, acquired_nodes, draw_ctx),
+ (Element::FeColorMatrix(_), ColorMatrix(p)) => p.render(ctx, acquired_nodes, draw_ctx),
(Element::FeComponentTransfer(ref inner), ComponentTransfer(node)) =>
FeComponentTransfer::render(&inner.element_impl, &node, ctx, acquired_nodes, draw_ctx),
(Element::FeComposite(ref inner), Composite(node)) =>
FeComposite::render(&inner.element_impl, &node, ctx, acquired_nodes, draw_ctx),
(Element::FeConvolveMatrix(ref inner), ConvolveMatrix(node)) =>
FeConvolveMatrix::render(&inner.element_impl, &node, ctx, acquired_nodes, draw_ctx),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]