diff --git a/ci/pull-container-image.sh b/ci/pull-container-image.sh new file mode 100644 index 0000000000000000000000000000000000000000..712676d4df0b867d1607ba72eafaed7a856eb16b --- /dev/null +++ b/ci/pull-container-image.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# +# Utility script so you can pull the container image from CI for local development. +# Run this script and follow the instructions; the script will tell you how +# to run "podman run" to launch a container that has the same environment as the +# one used during CI pipelines. You can debug things at leisure there. + +set -eu +set -o pipefail + +CONTAINER_BUILDS=ci/container_builds.yml + +if [ ! -f $CONTAINER_BUILDS ] +then + echo "Please run this from the toplevel source directory in librsvg" + exit 1 +fi + +tag=$(grep -e '^ BASE_TAG:' $CONTAINER_BUILDS | head -n 1 | sed -E 's/.*BASE_TAG: "(.+)"/\1/') +rust_version=$(grep -e '^ RUST_STABLE:' $CONTAINER_BUILDS | head -n 1 | sed -E 's/.*RUST_STABLE: "(.+)"/\1/') +full_tag=x86_64-$rust_version-$tag +echo full_tag=\"$full_tag\" + +image_name=registry.gitlab.gnome.org/gnome/librsvg/opensuse/tumbleweed:$full_tag + +echo pulling image $image_name +podman pull $image_name + +echo "" +echo "You can now run this:" +echo " podman run --rm -ti --cap-add=SYS_PTRACE -v \$(pwd):/srv/project -w /srv/project $image_name" +echo "" +echo "Don't forget to run this once inside the container:" +echo " source ci/env.sh" diff --git a/src/pattern.rs b/src/pattern.rs index 66bb66acbad0ead27b6a3b676c6894985f0d1916..42f6aeb3abf3b6a233cf712472b75e9803b387de 100644 --- a/src/pattern.rs +++ b/src/pattern.rs @@ -307,6 +307,14 @@ impl UnresolvedChildren { } } +fn nonempty_rect_from_bbox(bbox: &BoundingBox) -> Option { + match bbox.rect { + None => None, + Some(r) if r.is_empty() => None, + Some(r) => Some(r), + } +} + impl ResolvedPattern { fn node_with_children(&self) -> Option { match self.children { @@ -340,22 +348,19 @@ impl ResolvedPattern { let rect = self.get_rect(¶ms); - let bbrect = match bbox.rect { - None => return None, - Some(r) if r.is_empty() => return None, - Some(r) => r, - }; - // Create the pattern coordinate system let (width, height, coord_transform) = match self.units { - PatternUnits(CoordUnits::ObjectBoundingBox) => ( - rect.width() * bbrect.width(), - rect.height() * bbrect.height(), - Transform::new_translate( - bbrect.x0 + rect.x0 * bbrect.width(), - bbrect.y0 + rect.y0 * bbrect.height(), - ), - ), + PatternUnits(CoordUnits::ObjectBoundingBox) => { + let bbrect = nonempty_rect_from_bbox(bbox)?; + ( + rect.width() * bbrect.width(), + rect.height() * bbrect.height(), + Transform::new_translate( + bbrect.x0 + rect.x0 * bbrect.width(), + bbrect.y0 + rect.y0 * bbrect.height(), + ), + ) + } PatternUnits(CoordUnits::UserSpaceOnUse) => ( rect.width(), rect.height(), @@ -379,13 +384,12 @@ impl ResolvedPattern { Transform::new_scale(sw, sh).pre_translate(x, y) } else { - let PatternContentUnits(content_units) = self.content_units; - - match content_units { - CoordUnits::ObjectBoundingBox => { + match self.content_units { + PatternContentUnits(CoordUnits::ObjectBoundingBox) => { + let bbrect = nonempty_rect_from_bbox(bbox)?; Transform::new_scale(bbrect.width(), bbrect.height()) } - CoordUnits::UserSpaceOnUse => Transform::identity(), + PatternContentUnits(CoordUnits::UserSpaceOnUse) => Transform::identity(), } }; diff --git a/tests/Makefile.am b/tests/Makefile.am index 6cbc21b63404b7a8ac0f9117daa069b43521084e..62ad4544a7786e760079f02df21f1ee31dd2e5e7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -76,6 +76,7 @@ test_fixtures = \ $(wildcard $(srcdir)/fixtures/reftests/svg1.1/resources/*) \ $(wildcard $(srcdir)/fixtures/reftests/svg2/*.svg) \ $(wildcard $(srcdir)/fixtures/reftests/svg2/*.png) \ + $(wildcard $(srcdir)/fixtures/reftests/bugs-reftests/*.svg) \ $(wildcard $(srcdir)/fixtures/reftests/svg2-reftests/*.svg) \ $(wildcard $(srcdir)/fixtures/render-crash/*.svg) \ $(wildcard $(srcdir)/fixtures/text/*.svg) \ diff --git a/tests/fixtures/reftests/bugs-reftests/880-stroke-wide-line-ref.svg b/tests/fixtures/reftests/bugs-reftests/880-stroke-wide-line-ref.svg new file mode 100644 index 0000000000000000000000000000000000000000..a80e5632401ee10bac7f4d04b72e974c46ae4706 --- /dev/null +++ b/tests/fixtures/reftests/bugs-reftests/880-stroke-wide-line-ref.svg @@ -0,0 +1,4 @@ + + + + diff --git a/tests/fixtures/reftests/bugs-reftests/880-stroke-wide-line.svg b/tests/fixtures/reftests/bugs-reftests/880-stroke-wide-line.svg new file mode 100644 index 0000000000000000000000000000000000000000..4e22470f6f68bf0c41935799be40dd8bf3c3d32b --- /dev/null +++ b/tests/fixtures/reftests/bugs-reftests/880-stroke-wide-line.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/tests/src/reference.rs b/tests/src/reference.rs index 1eb088a01a04e892502447bc084e9ce4dc27ce04..665baec01ff608a4d3a2416e36245ccc91a8e955 100644 --- a/tests/src/reference.rs +++ b/tests/src/reference.rs @@ -400,3 +400,9 @@ test_svg_reference!( "tests/fixtures/reftests/svg2-reftests/mask-and-opacity.svg", "tests/fixtures/reftests/svg2-reftests/mask-and-opacity-ref.svg" ); + +test_svg_reference!( + bug_880_horizontal_vertical_stroked_lines, + "tests/fixtures/reftests/bugs-reftests/880-stroke-wide-line.svg", + "tests/fixtures/reftests/bugs-reftests/880-stroke-wide-line-ref.svg" +);