From 9be5867eb2f52c05a34024771ddffb6b981c878f Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Fri, 7 Jun 2024 18:10:29 +0300 Subject: [PATCH] LibWeb: Implement rejection by bounding box for PaintInnerBoxShadow Before this change we were painting inner shadows lying outside of viewport. Improves painting performance on Github and Twitter where this command is used a lot. --- Userland/Libraries/LibWeb/Painting/Command.cpp | 5 +++++ Userland/Libraries/LibWeb/Painting/Command.h | 1 + 2 files changed, 6 insertions(+) diff --git a/Userland/Libraries/LibWeb/Painting/Command.cpp b/Userland/Libraries/LibWeb/Painting/Command.cpp index cbd0a65d005..fd734114d4e 100644 --- a/Userland/Libraries/LibWeb/Painting/Command.cpp +++ b/Userland/Libraries/LibWeb/Painting/Command.cpp @@ -20,6 +20,11 @@ Gfx::IntRect PaintOuterBoxShadow::bounding_rect() const return get_outer_box_shadow_bounding_rect(box_shadow_params); } +Gfx::IntRect PaintInnerBoxShadow::bounding_rect() const +{ + return box_shadow_params.device_content_rect; +} + void PaintOuterBoxShadow::translate_by(Gfx::IntPoint const& offset) { box_shadow_params.device_content_rect.translate_by(offset); diff --git a/Userland/Libraries/LibWeb/Painting/Command.h b/Userland/Libraries/LibWeb/Painting/Command.h index 9ce66992a00..ac0fc5220c8 100644 --- a/Userland/Libraries/LibWeb/Painting/Command.h +++ b/Userland/Libraries/LibWeb/Painting/Command.h @@ -149,6 +149,7 @@ struct PaintOuterBoxShadow { struct PaintInnerBoxShadow { PaintBoxShadowParams box_shadow_params; + [[nodiscard]] Gfx::IntRect bounding_rect() const; void translate_by(Gfx::IntPoint const& offset); };