Skip to content

Commit

Permalink
Fix feImage rendering with a non-default position.
Browse files Browse the repository at this point in the history
Closes #685
  • Loading branch information
LaurenzV authored Dec 27, 2023
1 parent 701539c commit cb52988
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/resvg/src/filter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,15 @@ fn apply_image(
}
usvg::filter::ImageKind::Use(ref node) => {
let (sx, sy) = ts.get_scale();
let transform = tiny_skia::Transform::from_scale(sx, sy);

let transform = tiny_skia::Transform::from_row(
sx,
0.0,
0.0,
sy,
subregion.x() as f32,
subregion.y() as f32,
);

let ctx = crate::render::Context {
max_bbox: tiny_skia::IntRect::from_xywh(0, 0, region.width(), region.height())
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 @@ -196,6 +196,9 @@ use crate::render;
#[test] fn filters_feImage_with_subregion_3() { assert_eq!(render("tests/filters/feImage/with-subregion-3"), 0); }
#[test] fn filters_feImage_with_subregion_4() { assert_eq!(render("tests/filters/feImage/with-subregion-4"), 0); }
#[test] fn filters_feImage_with_subregion_5() { assert_eq!(render("tests/filters/feImage/with-subregion-5"), 0); }
#[test] fn filters_feImage_with_x_y_and_protruding_subregion_1() { assert_eq!(render("tests/filters/feImage/with-x-y-and-protruding-subregion-1"), 0); }
#[test] fn filters_feImage_with_x_y_and_protruding_subregion_2() { assert_eq!(render("tests/filters/feImage/with-x-y-and-protruding-subregion-2"), 0); }
#[test] fn filters_feImage_with_x_y() { assert_eq!(render("tests/filters/feImage/with-x-y"), 0); }
#[test] fn filters_feMerge_color_interpolation_filters_eq_linearRGB() { assert_eq!(render("tests/filters/feMerge/color-interpolation-filters=linearRGB"), 0); }
#[test] fn filters_feMerge_color_interpolation_filters_eq_sRGB() { assert_eq!(render("tests/filters/feMerge/color-interpolation-filters=sRGB"), 0); }
#[test] fn filters_feMerge_complex_transform() { assert_eq!(render("tests/filters/feMerge/complex-transform"), 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.
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/filters/feImage/with-x-y.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cb52988

Please sign in to comment.