Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ This changelog also contains important changes in dependencies.

## [Unreleased]

### Added

- `mix-blend-mode: plus-lighter` (Compositing and Blending Level 2).
- `feComposite` `operator="lighter"` (SVG 2).

### Fixed

- `dominant-baseline` is now correctly inherited by nested `<tspan>` elements,
Expand Down
1 change: 1 addition & 0 deletions crates/resvg/src/filter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ fn apply_composite(
Operator::Out => tiny_skia::BlendMode::SourceOut,
Operator::Atop => tiny_skia::BlendMode::SourceAtop,
Operator::Xor => tiny_skia::BlendMode::Xor,
Operator::Lighter => tiny_skia::BlendMode::Plus,
Operator::Arithmetic { .. } => tiny_skia::BlendMode::SourceOver,
};

Expand Down
1 change: 1 addition & 0 deletions crates/resvg/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ pub fn convert_blend_mode(mode: usvg::BlendMode) -> tiny_skia::BlendMode {
usvg::BlendMode::Saturation => tiny_skia::BlendMode::Saturation,
usvg::BlendMode::Color => tiny_skia::BlendMode::Color,
usvg::BlendMode::Luminosity => tiny_skia::BlendMode::Luminosity,
usvg::BlendMode::PlusLighter => tiny_skia::BlendMode::Plus,
}
}

Expand Down
3 changes: 3 additions & 0 deletions crates/resvg/tests/integration/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::render;
#[test] fn filters_enable_background_with_opacity_4() { assert_eq!(render("tests/filters/enable-background/with-opacity-4"), 0); }
#[test] fn filters_enable_background_with_transform() { assert_eq!(render("tests/filters/enable-background/with-transform"), 0); }
#[test] fn filters_feBlend_empty() { assert_eq!(render("tests/filters/feBlend/empty"), 0); }
#[test] fn filters_feBlend_invalid_mode_plus_lighter() { assert_eq!(render("tests/filters/feBlend/invalid-mode-plus-lighter"), 0); }
#[test] fn filters_feBlend_mode_eq_color_burn() { assert_eq!(render("tests/filters/feBlend/mode=color-burn"), 0); }
#[test] fn filters_feBlend_mode_eq_darken() { assert_eq!(render("tests/filters/feBlend/mode=darken"), 0); }
#[test] fn filters_feBlend_mode_eq_hue() { assert_eq!(render("tests/filters/feBlend/mode=hue"), 0); }
Expand Down Expand Up @@ -90,6 +91,7 @@ use crate::render;
#[test] fn filters_feComposite_operator_eq_arithmetic() { assert_eq!(render("tests/filters/feComposite/operator=arithmetic"), 0); }
#[test] fn filters_feComposite_operator_eq_atop() { assert_eq!(render("tests/filters/feComposite/operator=atop"), 0); }
#[test] fn filters_feComposite_operator_eq_in() { assert_eq!(render("tests/filters/feComposite/operator=in"), 0); }
#[test] fn filters_feComposite_operator_eq_lighter() { assert_eq!(render("tests/filters/feComposite/operator=lighter"), 0); }
#[test] fn filters_feComposite_operator_eq_out() { assert_eq!(render("tests/filters/feComposite/operator=out"), 0); }
#[test] fn filters_feComposite_operator_eq_over() { assert_eq!(render("tests/filters/feComposite/operator=over"), 0); }
#[test] fn filters_feComposite_operator_eq_xor() { assert_eq!(render("tests/filters/feComposite/operator=xor"), 0); }
Expand Down Expand Up @@ -836,6 +838,7 @@ use crate::render;
#[test] fn painting_mix_blend_mode_opacity_on_element() { assert_eq!(render("tests/painting/mix-blend-mode/opacity-on-element"), 0); }
#[test] fn painting_mix_blend_mode_opacity_on_group() { assert_eq!(render("tests/painting/mix-blend-mode/opacity-on-group"), 0); }
#[test] fn painting_mix_blend_mode_overlay() { assert_eq!(render("tests/painting/mix-blend-mode/overlay"), 0); }
#[test] fn painting_mix_blend_mode_plus_lighter() { assert_eq!(render("tests/painting/mix-blend-mode/plus-lighter"), 0); }
#[test] fn painting_mix_blend_mode_saturation() { assert_eq!(render("tests/painting/mix-blend-mode/saturation"), 0); }
#[test] fn painting_mix_blend_mode_screen() { assert_eq!(render("tests/painting/mix-blend-mode/screen"), 0); }
#[test] fn painting_mix_blend_mode_soft_light() { assert_eq!(render("tests/painting/mix-blend-mode/soft-light"), 0); }
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions crates/resvg/tests/tests/filters/feComposite/operator=lighter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions crates/resvg/tests/tests/painting/mix-blend-mode/plus-lighter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions crates/usvg/src/parser/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ fn convert_composite(fe: SvgNode, primitives: &[Primitive]) -> Kind {
"out" => CompositeOperator::Out,
"atop" => CompositeOperator::Atop,
"xor" => CompositeOperator::Xor,
"lighter" => CompositeOperator::Lighter,
"arithmetic" => CompositeOperator::Arithmetic {
k1: fe.attribute(AId::K1).unwrap_or(0.0),
k2: fe.attribute(AId::K2).unwrap_or(0.0),
Expand Down
3 changes: 2 additions & 1 deletion crates/usvg/src/parser/svgtree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ impl<'a, 'input: 'a> FromValue<'a, 'input> for ImageRendering {
}

impl<'a, 'input: 'a> FromValue<'a, 'input> for BlendMode {
fn parse(_: SvgNode, _: AId, value: &str) -> Option<Self> {
fn parse(_: SvgNode, aid: AId, value: &str) -> Option<Self> {
match value {
"normal" => Some(BlendMode::Normal),
"multiply" => Some(BlendMode::Multiply),
Expand All @@ -1064,6 +1064,7 @@ impl<'a, 'input: 'a> FromValue<'a, 'input> for BlendMode {
"saturation" => Some(BlendMode::Saturation),
"color" => Some(BlendMode::Color),
"luminosity" => Some(BlendMode::Luminosity),
"plus-lighter" if aid == AId::MixBlendMode => Some(BlendMode::PlusLighter),
_ => None,
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/usvg/src/tree/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ pub enum CompositeOperator {
Out,
Atop,
Xor,
Lighter,
Arithmetic { k1: f32, k2: f32, k3: f32, k4: f32 },
}

Expand Down
2 changes: 2 additions & 0 deletions crates/usvg/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ pub enum BlendMode {
Saturation,
Color,
Luminosity,
PlusLighter,
}

impl Default for BlendMode {
Expand Down Expand Up @@ -257,6 +258,7 @@ impl Display for BlendMode {
BlendMode::Saturation => "saturation",
BlendMode::Color => "color",
BlendMode::Luminosity => "luminosity",
BlendMode::PlusLighter => "plus-lighter",
};
write!(f, "{blend_mode}")
}
Expand Down
1 change: 1 addition & 0 deletions crates/usvg/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ fn write_filters(tree: &Tree, opt: &WriteOptions, xml: &mut XmlWriter) {
filter::CompositeOperator::Out => "out",
filter::CompositeOperator::Atop => "atop",
filter::CompositeOperator::Xor => "xor",
filter::CompositeOperator::Lighter => "lighter",
filter::CompositeOperator::Arithmetic { .. } => "arithmetic",
},
);
Expand Down
2 changes: 2 additions & 0 deletions docs/svg2-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ Basically everything from [CSS Text Module Level 3](https://www.w3.org/TR/css-te
- [x] (partial support) A [`paint-order`](https://www.w3.org/TR/SVG2/painting.html#PaintOrder) property.
- [x] `context-fill` and `context-stroke` variants to the [`<paint>`](https://www.w3.org/TR/SVG2/painting.html#SpecifyingPaint) type.
- [x] A [`mix-blend-mode`](https://www.w3.org/TR/compositing-1/#mix-blend-mode) property.
- [x] A `plus-lighter` variant to the [`mix-blend-mode`](https://drafts.csswg.org/compositing-2/#mix-blend-mode) property.
- [x] An [`isolation`](https://www.w3.org/TR/compositing-1/#isolation) property.
- [ ] `left`, `center` and `right` variants to `refX` and `refY` properties of the [`marker`](https://www.w3.org/TR/SVG2/painting.html#MarkerElement) element.
- [x] An `auto-start-reverse` variant to [`orient`](https://www.w3.org/TR/SVG2/painting.html#OrientAttribute) property of the [`marker`](https://www.w3.org/TR/SVG2/painting.html#MarkerElement) element
Expand Down Expand Up @@ -252,6 +253,7 @@ Basically everything from [CSS Text Module Level 3](https://www.w3.org/TR/css-te
- [x] [Filter functions](https://www.w3.org/TR/filter-effects-1/#filter-functions).
- [x] New [blend modes](https://www.w3.org/TR/compositing-1/#ltblendmodegt) to [`feBlend`](https://www.w3.org/TR/filter-effects-1/#feBlendElement) element.
- [ ] A [`no-composite`](https://www.w3.org/TR/filter-effects-1/#element-attrdef-feblend-no-composite) property to [`feBlend`](https://www.w3.org/TR/filter-effects-1/#feBlendElement) element.
- [x] A `lighter` variant to the [`operator`](https://www.w3.org/TR/filter-effects-1/#element-attrdef-fecomposite-operator) attribute of the [`feComposite`](https://www.w3.org/TR/filter-effects-1/#feCompositeElement) element.

### Changed

Expand Down
Loading