[librsvg: 9/23] feComposite - resolve and render separately
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 9/23] feComposite - resolve and render separately
- Date: Thu, 11 Mar 2021 23:12:24 +0000 (UTC)
commit 881012327c4333842e35538cb1e6cdc0c00fdcf0
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Mar 11 13:30:52 2021 -0600
feComposite - resolve and render separately
src/filters/composite.rs | 50 +++++++++++++++++++++++++++++++++++++++---------
src/filters/mod.rs | 5 ++---
2 files changed, 43 insertions(+), 12 deletions(-)
---
diff --git a/src/filters/composite.rs b/src/filters/composite.rs
index d5fe198d..209310c0 100644
--- a/src/filters/composite.rs
+++ b/src/filters/composite.rs
@@ -7,6 +7,7 @@ use crate::element::{ElementResult, SetAttributes};
use crate::error::*;
use crate::node::{CascadedValues, Node};
use crate::parsers::{Parse, ParseValue};
+use crate::property_defs::ColorInterpolationFilters;
use crate::xml::Attributes;
use super::context::{FilterContext, FilterOutput, FilterResult};
@@ -35,6 +36,19 @@ pub struct FeComposite {
k4: f64,
}
+/// Resolved `feComposite` primitive for rendering.
+pub struct Composite {
+ base: Primitive,
+ in1: Input,
+ in2: Input,
+ operator: Operator,
+ k1: f64,
+ k2: f64,
+ k3: f64,
+ k4: f64,
+ color_interpolation_filters: ColorInterpolationFilters,
+}
+
impl Default for FeComposite {
/// Constructs a new `Composite` with empty properties.
#[inline]
@@ -73,20 +87,25 @@ impl SetAttributes for FeComposite {
}
}
-impl FeComposite {
+impl Composite {
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_2 = ctx.get_input(acquired_nodes, draw_ctx, &self.in2, cif)?;
+ let input_1 = ctx.get_input(
+ acquired_nodes,
+ draw_ctx,
+ &self.in1,
+ self.color_interpolation_filters,
+ )?;
+ let input_2 = ctx.get_input(
+ acquired_nodes,
+ draw_ctx,
+ &self.in2,
+ self.color_interpolation_filters,
+ )?;
let bounds = self
.base
.get_bounds(ctx)?
@@ -120,7 +139,20 @@ impl FeComposite {
impl FilterEffect for FeComposite {
fn resolve(&self, node: &Node) -> Result<PrimitiveParams, FilterError> {
- Ok(PrimitiveParams::Composite(node.clone()))
+ let cascaded = CascadedValues::new_from_node(node);
+ let values = cascaded.get();
+
+ Ok(PrimitiveParams::Composite(Composite {
+ base: self.base.clone(),
+ in1: self.in1.clone(),
+ in2: self.in2.clone(),
+ operator: self.operator.clone(),
+ k1: self.k1.clone(),
+ k2: self.k2.clone(),
+ k3: self.k3.clone(),
+ k4: self.k4.clone(),
+ color_interpolation_filters: values.color_interpolation_filters(),
+ }))
}
}
diff --git a/src/filters/mod.rs b/src/filters/mod.rs
index 955f572c..a2026004 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 composite::FeComposite;
use convolve_matrix::FeConvolveMatrix;
use displacement_map::FeDisplacementMap;
use flood::FeFlood;
@@ -75,7 +74,7 @@ pub enum PrimitiveParams {
Blend(blend::Blend),
ColorMatrix(color_matrix::ColorMatrix),
ComponentTransfer(component_transfer::ComponentTransfer),
- Composite(Node),
+ Composite(composite::Composite),
ConvolveMatrix(Node),
DiffuseLighting(Node),
DisplacementMap(Node),
@@ -326,7 +325,7 @@ fn render_primitive(
(Element::FeBlend(_), Blend(p)) => p.render(ctx, acquired_nodes, draw_ctx),
(Element::FeColorMatrix(_), ColorMatrix(p)) => p.render(ctx, acquired_nodes, draw_ctx),
(Element::FeComponentTransfer(_), ComponentTransfer(p)) => p.render(ctx, acquired_nodes, draw_ctx),
- (Element::FeComposite(ref inner), Composite(node)) =>
FeComposite::render(&inner.element_impl, &node, ctx, acquired_nodes, draw_ctx),
+ (Element::FeComposite(_), Composite(p)) => p.render(ctx, acquired_nodes, draw_ctx),
(Element::FeConvolveMatrix(ref inner), ConvolveMatrix(node)) =>
FeConvolveMatrix::render(&inner.element_impl, &node, ctx, acquired_nodes, draw_ctx),
(Element::FeDiffuseLighting(ref inner), DiffuseLighting(node)) =>
FeDiffuseLighting::render(&inner.element_impl, &node, ctx, acquired_nodes, draw_ctx),
(Element::FeDisplacementMap(ref inner), DisplacementMap(node)) =>
FeDisplacementMap::render(&inner.element_impl, &node, ctx, acquired_nodes, draw_ctx),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]