summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp46
1 files changed, 2 insertions, 44 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp b/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp
index 2333aec577..a1956a23a8 100644
--- a/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp
+++ b/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2023, MacDue <macdue@dueutil.tech>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -49,50 +50,7 @@ void SVGGeometryPaintable::paint(PaintContext& context, PaintPhase phase) const
context.painter().add_clip_rect(context.enclosing_device_rect(absolute_rect()).to_type<int>());
- Gfx::Path path = const_cast<SVG::SVGGeometryElement&>(geometry_element).get_path();
-
- if (maybe_view_box.has_value()) {
- Gfx::Path new_path;
- auto scaling = layout_box().viewbox_scaling();
- auto origin = layout_box().viewbox_origin();
-
- auto transform_point = [&scaling, &origin](Gfx::FloatPoint point) -> Gfx::FloatPoint {
- auto new_point = point;
- new_point.translate_by({ -origin.x(), -origin.y() });
- new_point.scale_by(scaling);
- return new_point;
- };
-
- for (auto& segment : path.segments()) {
- switch (segment->type()) {
- case Gfx::Segment::Type::Invalid:
- break;
- case Gfx::Segment::Type::MoveTo:
- new_path.move_to(transform_point(segment->point()));
- break;
- case Gfx::Segment::Type::LineTo:
- new_path.line_to(transform_point(segment->point()));
- break;
- case Gfx::Segment::Type::QuadraticBezierCurveTo: {
- auto& quadratic_bezier_segment = static_cast<Gfx::QuadraticBezierCurveSegment const&>(*segment);
- new_path.quadratic_bezier_curve_to(transform_point(quadratic_bezier_segment.through()), transform_point(quadratic_bezier_segment.point()));
- break;
- }
- case Gfx::Segment::Type::CubicBezierCurveTo: {
- auto& cubic_bezier_segment = static_cast<Gfx::CubicBezierCurveSegment const&>(*segment);
- new_path.cubic_bezier_curve_to(transform_point(cubic_bezier_segment.through_0()), transform_point(cubic_bezier_segment.through_1()), transform_point(cubic_bezier_segment.point()));
- break;
- }
- case Gfx::Segment::Type::EllipticalArcTo: {
- auto& elliptical_arc_segment = static_cast<Gfx::EllipticalArcSegment const&>(*segment);
- new_path.elliptical_arc_to(transform_point(elliptical_arc_segment.point()), elliptical_arc_segment.radii().scaled_by(scaling, scaling), elliptical_arc_segment.x_axis_rotation(), elliptical_arc_segment.large_arc(), elliptical_arc_segment.sweep());
- break;
- }
- }
- }
-
- path = new_path;
- }
+ Gfx::Path path = const_cast<SVG::SVGGeometryElement&>(geometry_element).get_path().copy_transformed(Gfx::AffineTransform {}.multiply(layout_box().layout_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