From e0a79efeaeaa70ba1086257fd3ff48fda36e27ad Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 9 Jul 2021 15:18:49 +0200 Subject: [PATCH] LibGfx: Make enclosing_int_rect(FloatRect) actually enclose the rect --- Userland/Libraries/LibGfx/Rect.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibGfx/Rect.h b/Userland/Libraries/LibGfx/Rect.h index 1ec5f2273d..6343845a94 100644 --- a/Userland/Libraries/LibGfx/Rect.h +++ b/Userland/Libraries/LibGfx/Rect.h @@ -612,12 +612,11 @@ using FloatRect = Rect; [[nodiscard]] ALWAYS_INLINE IntRect enclosing_int_rect(FloatRect const& float_rect) { - return { - (int)float_rect.x(), - (int)float_rect.y(), - (int)ceilf(float_rect.width()), - (int)ceilf(float_rect.height()), - }; + int x1 = floorf(float_rect.x()); + int y1 = floorf(float_rect.y()); + int x2 = ceilf(float_rect.x() + float_rect.width()); + int y2 = ceilf(float_rect.y() + float_rect.height()); + return Gfx::IntRect::from_two_points({ x1, y1 }, { x2, y2 }); } }