Browse Source

LibWeb: Skip empty paint borders commands in RecordingPainter

With this change, we create substantially fewer border painting
commands, which means fewer reallocations of the vector that stores
commands.

This makes the rendering of
https://html.spec.whatwg.org/multipage/browsing-the-web.html visibly
faster, where we allocated ~10 of such commands now vs ~8000 before.
Aliaksandr Kalenik 1 year ago
parent
commit
c7e22c7a72
1 changed files with 2 additions and 0 deletions
  1. 2 0
      Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp

+ 2 - 0
Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp

@@ -411,6 +411,8 @@ void RecordingPainter::draw_triangle_wave(Gfx::IntPoint a_p1, Gfx::IntPoint a_p2
 
 void RecordingPainter::paint_borders(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.bottom.width == 0 && borders_data.left.width == 0)
+        return;
     push_command(PaintBorders { border_rect, corner_radii, borders_data });
 }