summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Painting
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2023-04-15 15:32:17 +0100
committerAndreas Kling <kling@serenityos.org>2023-04-15 19:28:13 +0200
commitf9c61e3ba740adfd82bc2147db2f47eb659faff7 (patch)
tree684fbc20b4df112147d06a6d0c80e5656e13c562 /Userland/Libraries/LibWeb/Painting
parentcb79c6bc2f73dcbec927e31736056ead8a67a7a2 (diff)
downloadserenity-f9c61e3ba740adfd82bc2147db2f47eb659faff7.zip
LibWeb: Scale SVG stroke-width based on viewbox
This fixes the clipping of strokes in quite a few cases and now fixes the Gartic Phone logo :^) (Layout test updated but no visible changes there)
Diffstat (limited to 'Userland/Libraries/LibWeb/Painting')
-rw-r--r--Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp b/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp
index 07aa283de4..77b0c2ad29 100644
--- a/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp
+++ b/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp
@@ -71,7 +71,9 @@ void SVGGeometryPaintable::paint(PaintContext& context, PaintPhase phase) const
auto transform = layout_box().layout_transform();
if (!transform.has_value())
return;
- Gfx::Path path = const_cast<SVG::SVGGeometryElement&>(geometry_element).get_path().copy_transformed(Gfx::AffineTransform {}.scale(css_scale, css_scale).multiply(*transform));
+
+ auto paint_transform = Gfx::AffineTransform {}.scale(css_scale, css_scale).multiply(*transform);
+ Gfx::Path path = const_cast<SVG::SVGGeometryElement&>(geometry_element).get_path().copy_transformed(paint_transform);
if (auto fill_color = geometry_element.fill_color().value_or(svg_context.fill_color()); fill_color.alpha() > 0) {
// We need to fill the path before applying the stroke, however the filled
@@ -91,7 +93,8 @@ void SVGGeometryPaintable::paint(PaintContext& context, PaintPhase phase) const
painter.stroke_path(
path,
stroke_color,
- geometry_element.stroke_width().value_or(svg_context.stroke_width()) * context.device_pixels_per_css_pixel());
+ // Note: This is assuming .x_scale() == .y_scale() (which it does currently).
+ geometry_element.stroke_width().value_or(svg_context.stroke_width()) * paint_transform.x_scale());
}
}