mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 18:02:20 +00:00
LibWeb: Plumb svg stroking state to DisplayListPlayerSkia
The state is still ignored there, so no behavior change, but this should make it fairly easy to actually implement complete stroking support for SVGs.
This commit is contained in:
parent
201648485f
commit
f4b0d17e4b
Notes:
github-actions[bot]
2024-11-22 11:22:20 +00:00
Author: https://github.com/nico
Commit: f4b0d17e4b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2490
7 changed files with 96 additions and 3 deletions
|
@ -129,17 +129,51 @@ void SVGPathPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
});
|
||||
}
|
||||
|
||||
auto stroke_linecap = graphics_element.stroke_linecap().value_or(CSS::StrokeLinecap::Butt);
|
||||
(void)stroke_linecap; // FIXME: Use
|
||||
Gfx::Path::CapStyle cap_style;
|
||||
switch (graphics_element.stroke_linecap().value_or(CSS::InitialValues::stroke_linecap())) {
|
||||
case CSS::StrokeLinecap::Butt:
|
||||
cap_style = Gfx::Path::CapStyle::Butt;
|
||||
break;
|
||||
case CSS::StrokeLinecap::Round:
|
||||
cap_style = Gfx::Path::CapStyle::Round;
|
||||
break;
|
||||
case CSS::StrokeLinecap::Square:
|
||||
cap_style = Gfx::Path::CapStyle::Square;
|
||||
break;
|
||||
}
|
||||
|
||||
Gfx::Path::JoinStyle join_style;
|
||||
switch (graphics_element.stroke_linejoin().value_or(CSS::InitialValues::stroke_linejoin())) {
|
||||
case CSS::StrokeLinejoin::Miter:
|
||||
join_style = Gfx::Path::JoinStyle::Miter;
|
||||
break;
|
||||
case CSS::StrokeLinejoin::Round:
|
||||
join_style = Gfx::Path::JoinStyle::Round;
|
||||
break;
|
||||
case CSS::StrokeLinejoin::Bevel:
|
||||
join_style = Gfx::Path::JoinStyle::Bevel;
|
||||
break;
|
||||
}
|
||||
|
||||
auto miter_limit = graphics_element.stroke_miterlimit().value_or(CSS::InitialValues::stroke_miterlimit()).resolved(layout_node());
|
||||
|
||||
auto stroke_opacity = graphics_element.stroke_opacity().value_or(1);
|
||||
|
||||
// Note: This is assuming .x_scale() == .y_scale() (which it does currently).
|
||||
auto viewbox_scale = paint_transform.x_scale();
|
||||
float stroke_thickness = graphics_element.stroke_width().value_or(1) * viewbox_scale;
|
||||
auto stroke_dasharray = graphics_element.stroke_dasharray();
|
||||
for (auto& value : stroke_dasharray)
|
||||
value *= viewbox_scale;
|
||||
float stroke_dashoffset = graphics_element.stroke_dashoffset().value_or(0) * viewbox_scale;
|
||||
|
||||
if (auto paint_style = graphics_element.stroke_paint_style(paint_context); paint_style.has_value()) {
|
||||
context.display_list_recorder().stroke_path({
|
||||
.cap_style = cap_style,
|
||||
.join_style = join_style,
|
||||
.miter_limit = static_cast<float>(miter_limit),
|
||||
.dash_array = stroke_dasharray,
|
||||
.dash_offset = stroke_dashoffset,
|
||||
.path = path,
|
||||
.paint_style = *paint_style,
|
||||
.thickness = stroke_thickness,
|
||||
|
@ -148,6 +182,11 @@ void SVGPathPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
});
|
||||
} else if (auto stroke_color = graphics_element.stroke_color(); stroke_color.has_value()) {
|
||||
context.display_list_recorder().stroke_path({
|
||||
.cap_style = cap_style,
|
||||
.join_style = join_style,
|
||||
.miter_limit = static_cast<float>(miter_limit),
|
||||
.dash_array = stroke_dasharray,
|
||||
.dash_offset = stroke_dashoffset,
|
||||
.path = path,
|
||||
.color = stroke_color->with_opacity(stroke_opacity),
|
||||
.thickness = stroke_thickness,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue