1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:27:46 +00:00

LibWeb: Introduce dedicated painting command for borders

Currently, in CPU painter, border painting is implemented by building
a Gfx::Path that is filled by Gfx::AntiAliasingPainter. In the GPU
painter, we will likely want to do something different, and with a
special command, it becomes possible.

Also, by making this change, the CPU executor also benefits because now
we can skip building paths for borders that are out of the viewport.
This commit is contained in:
Aliaksandr Kalenik 2023-11-19 23:19:51 +01:00 committed by Andreas Kling
parent 70353b79af
commit 29ff1f67be
11 changed files with 50 additions and 12 deletions

View file

@ -115,7 +115,7 @@ Gfx::Color border_color(BorderEdge edge, BordersDataDevicePixels const& borders_
return border_data.color;
}
void paint_border(RecordingPainter& painter, BorderEdge edge, DevicePixelRect const& rect, Gfx::AntiAliasingPainter::CornerRadius const& radius, Gfx::AntiAliasingPainter::CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path& path, bool last)
void paint_border(Gfx::Painter& painter, BorderEdge edge, DevicePixelRect const& rect, Gfx::AntiAliasingPainter::CornerRadius const& radius, Gfx::AntiAliasingPainter::CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path& path, bool last)
{
auto const& border_data = [&] {
switch (edge) {
@ -243,7 +243,8 @@ void paint_border(RecordingPainter& painter, BorderEdge edge, DevicePixelRect co
// If joined borders have the same color, combine them to draw together.
if (ready_to_draw) {
path.close_all_subpaths();
painter.fill_path({ .path = path, .color = color, .winding_rule = Gfx::Painter::WindingRule::EvenOdd });
Gfx::AntiAliasingPainter aa_painter(painter);
aa_painter.fill_path(path, color, Gfx::Painter::WindingRule::EvenOdd);
path.clear();
}
};
@ -543,7 +544,7 @@ void paint_border(RecordingPainter& painter, BorderEdge edge, DevicePixelRect co
}
}
void paint_all_borders(RecordingPainter& painter, DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const& borders_data)
void paint_all_borders(Gfx::Painter& painter, DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const& borders_data)
{
if (borders_data.top.width <= 0 && borders_data.right.width <= 0 && borders_data.left.width <= 0 && borders_data.bottom.width <= 0)
return;