summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/Rect.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-07-09 15:18:49 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-09 18:05:52 +0200
commite0a79efeaeaa70ba1086257fd3ff48fda36e27ad (patch)
tree5ffa3fb868fec3779ed24e1c205214c510612b3a /Userland/Libraries/LibGfx/Rect.h
parentc59c97036393e512b5d7484115645ca74a1bdf94 (diff)
downloadserenity-e0a79efeaeaa70ba1086257fd3ff48fda36e27ad.zip
LibGfx: Make enclosing_int_rect(FloatRect) actually enclose the rect
Diffstat (limited to 'Userland/Libraries/LibGfx/Rect.h')
-rw-r--r--Userland/Libraries/LibGfx/Rect.h11
1 files 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<float>;
[[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 });
}
}