1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

LibWeb: Don't use paint styles for solid color CRC2D fills

It is faster to avoid the extra overhead/indirection of paint styles if
possible.
This commit is contained in:
MacDue 2023-06-07 23:04:01 +01:00 committed by Andreas Kling
parent 87c103e210
commit 727ff6cf59

View file

@ -265,11 +265,17 @@ static Gfx::Painter::WindingRule parse_fill_rule(StringView fill_rule)
return Gfx::Painter::WindingRule::Nonzero;
}
void CanvasRenderingContext2D::fill_internal(Gfx::Path& path, StringView fill_rule)
void CanvasRenderingContext2D::fill_internal(Gfx::Path& path, StringView fill_rule_value)
{
draw_clipped([&](auto& painter) {
path.close_all_subpaths();
painter.fill_path(path, *drawing_state().fill_style.to_gfx_paint_style(), parse_fill_rule(fill_rule));
auto& drawing_state = this->drawing_state();
auto fill_rule = parse_fill_rule(fill_rule_value);
if (auto color = drawing_state.fill_style.as_color(); color.has_value()) {
painter.fill_path(path, *color, fill_rule);
} else {
painter.fill_path(path, drawing_state.fill_style.to_gfx_paint_style(), fill_rule);
}
return path.bounding_box();
});
}