LibWeb/Painting: Apply clip and mask operations that are off-screen

These operations should still apply even if they are off screen, because
they affect painting of things outside of their bounding rectangles.

This commit makes us always apply these, regardless of if they are in
the visible region. However, if they are outside that region, we
replace them with simple clip-rect commands, which have the same
effect (not painting anything) but are cheaper than computing a full
mask bitmap.
This commit is contained in:
Sam Atkins 2024-11-13 12:29:17 +00:00 committed by Alexander Kalenik
commit a6822986bb
Notes: github-actions[bot] 2024-11-13 15:11:18 +00:00
4 changed files with 83 additions and 0 deletions

View file

@ -105,6 +105,8 @@ struct Translate {
struct AddClipRect {
Gfx::IntRect rect;
[[nodiscard]] Gfx::IntRect bounding_rect() const { return rect; }
bool is_clip_or_mask() const { return true; }
void translate_by(Gfx::IntPoint const& offset) { rect.translate_by(offset); }
};
@ -349,6 +351,7 @@ struct AddRoundedRectClip {
CornerClip corner_clip;
[[nodiscard]] Gfx::IntRect bounding_rect() const { return border_rect; }
bool is_clip_or_mask() const { return true; }
void translate_by(Gfx::IntPoint const& offset) { border_rect.translate_by(offset); }
};
@ -358,6 +361,7 @@ struct AddMask {
Gfx::IntRect rect;
[[nodiscard]] Gfx::IntRect bounding_rect() const { return rect; }
bool is_clip_or_mask() const { return true; }
void translate_by(Gfx::IntPoint const& offset)
{