diff options
author | MacDue <macdue@dueutil.tech> | 2022-06-17 00:24:30 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-06-17 09:37:39 +0100 |
commit | c491ab7523215af92d9ca2cc8ed97fc80f16683a (patch) | |
tree | 65ff4db145d29c92d2ff31fd423698c19154e9fe /Userland/Libraries/LibWeb | |
parent | c4ef4fcd726a8450cf82c3e794f3eaeeb9c3d6bb (diff) | |
download | serenity-c491ab7523215af92d9ca2cc8ed97fc80f16683a.zip |
LibWeb: Only paint the background image on integer steps
This avoids excessive over painting.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp b/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp index 596d98e200..3554219bf9 100644 --- a/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp @@ -261,13 +261,18 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet float initial_image_x = image_rect.x(); float image_y = image_rect.y(); + Optional<Gfx::IntRect> last_int_image_rect; + while (image_y < clip_rect.bottom()) { image_rect.set_y(image_y); float image_x = initial_image_x; while (image_x < clip_rect.right()) { image_rect.set_x(image_x); - painter.draw_scaled_bitmap(image_rect.to_rounded<int>(), image, image.rect(), 1.0f, Gfx::Painter::ScalingMode::BilinearBlend); + auto int_image_rect = image_rect.to_rounded<int>(); + if (int_image_rect != last_int_image_rect) + painter.draw_scaled_bitmap(int_image_rect, image, image.rect(), 1.0f, Gfx::Painter::ScalingMode::BilinearBlend); + last_int_image_rect = int_image_rect; if (!repeat_x) break; image_x += x_step; |