LibWeb: Use shape-rendering to control anti aliasing for SVG paths

Anti-aliasing is disabled if `shape-rendering` is set to
`optimizeSpeed` or `crispEdges`.
This commit is contained in:
Tim Ledbetter 2025-08-18 16:21:09 +01:00 committed by Sam Atkins
parent 1d745884be
commit cfc6439c12
Notes: github-actions[bot] 2025-08-19 08:48:50 +00:00
10 changed files with 43 additions and 4 deletions

View file

@ -98,6 +98,7 @@ void SVGPathPaintable::paint(DisplayListRecordingContext& context, PaintPhase ph
.path = closed_path(),
.paint_style_or_color = Gfx::Color(Color::Black),
.winding_rule = to_gfx_winding_rule(graphics_element.clip_rule().value_or(SVG::ClipRule::Nonzero)),
.should_anti_alias = should_anti_alias(),
});
return;
}
@ -116,12 +117,14 @@ void SVGPathPaintable::paint(DisplayListRecordingContext& context, PaintPhase ph
.opacity = fill_opacity,
.paint_style_or_color = *paint_style,
.winding_rule = winding_rule,
.should_anti_alias = should_anti_alias(),
});
} else if (auto fill_color = graphics_element.fill_color(); fill_color.has_value()) {
context.display_list_recorder().fill_path({
.path = closed_path(),
.paint_style_or_color = fill_color->with_opacity(fill_opacity),
.winding_rule = winding_rule,
.should_anti_alias = should_anti_alias(),
});
}
@ -177,6 +180,7 @@ void SVGPathPaintable::paint(DisplayListRecordingContext& context, PaintPhase ph
.opacity = stroke_opacity,
.paint_style_or_color = *paint_style,
.thickness = stroke_thickness,
.should_anti_alias = should_anti_alias(),
});
} else if (auto stroke_color = graphics_element.stroke_color(); stroke_color.has_value()) {
context.display_list_recorder().stroke_path({
@ -188,6 +192,7 @@ void SVGPathPaintable::paint(DisplayListRecordingContext& context, PaintPhase ph
.path = path,
.paint_style_or_color = stroke_color->with_opacity(stroke_opacity),
.thickness = stroke_thickness,
.should_anti_alias = should_anti_alias(),
});
}
}