LibGfx: Add rounded_int_rect() function for Rects
We were seeing a problem in LibWeb, where layout elements would be 1px larger than they should be, due to layout positions using float values, and then converting using `enclosing_int_rect()`. `rounded_int_rect()` replaces that use, by maintaining the original rect's size.
This commit is contained in:
parent
8817ea83d6
commit
0b7eefd4e5
Notes:
sideshowbarker
2024-07-18 03:35:05 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/0b7eefd4e5f Pull-request: https://github.com/SerenityOS/serenity/pull/10166
1 changed files with 5 additions and 0 deletions
|
@ -715,6 +715,11 @@ using FloatRect = Rect<float>;
|
|||
return Gfx::IntRect::from_two_points({ x1, y1 }, { x2, y2 });
|
||||
}
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE IntRect rounded_int_rect(FloatRect const& float_rect)
|
||||
{
|
||||
return IntRect { floorf(float_rect.x()), floorf(float_rect.y()), roundf(float_rect.width()), roundf(float_rect.height()) };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
|
|
Loading…
Add table
Reference in a new issue