mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:58:11 +00:00
LibGfx+Everywhere: Change Gfx::Rect
to be endpoint exclusive
Previously, calling `.right()` on a `Gfx::Rect` would return the last column's coordinate still inside the rectangle, or `left + width - 1`. This is called 'endpoint inclusive' and does not make a lot of sense for `Gfx::Rect<float>` where a rectangle of width 5 at position (0, 0) would return 4 as its right side. This same problem exists for `.bottom()`. This changes `Gfx::Rect` to be endpoint exclusive, which gives us the nice property that `width = right - left` and `height = bottom - top`. It enables us to treat `Gfx::Rect<int>` and `Gfx::Rect<float>` exactly the same. All users of `Gfx::Rect` have been updated accordingly.
This commit is contained in:
parent
b7f4363791
commit
f391ccfe53
88 changed files with 524 additions and 518 deletions
|
@ -231,9 +231,9 @@ ALWAYS_INLINE void Device::rasterize(Gfx::IntRect& render_bounds, CB1 set_covera
|
|||
|
||||
// Quad bounds
|
||||
auto const render_bounds_left = render_bounds.left();
|
||||
auto const render_bounds_right = render_bounds.right();
|
||||
auto const render_bounds_right = render_bounds.right() - 1;
|
||||
auto const render_bounds_top = render_bounds.top();
|
||||
auto const render_bounds_bottom = render_bounds.bottom();
|
||||
auto const render_bounds_bottom = render_bounds.bottom() - 1;
|
||||
auto const qx0 = render_bounds_left & ~1;
|
||||
auto const qx1 = render_bounds_right & ~1;
|
||||
auto const qy0 = render_bounds_top & ~1;
|
||||
|
@ -678,9 +678,9 @@ void Device::rasterize_triangle(Triangle& triangle)
|
|||
// Calculate render bounds based on the triangle's vertices
|
||||
Gfx::IntRect render_bounds;
|
||||
render_bounds.set_left(min(min(v0.x(), v1.x()), v2.x()) / subpixel_factor);
|
||||
render_bounds.set_right(max(max(v0.x(), v1.x()), v2.x()) / subpixel_factor);
|
||||
render_bounds.set_right(max(max(v0.x(), v1.x()), v2.x()) / subpixel_factor + 1);
|
||||
render_bounds.set_top(min(min(v0.y(), v1.y()), v2.y()) / subpixel_factor);
|
||||
render_bounds.set_bottom(max(max(v0.y(), v1.y()), v2.y()) / subpixel_factor);
|
||||
render_bounds.set_bottom(max(max(v0.y(), v1.y()), v2.y()) / subpixel_factor + 1);
|
||||
|
||||
// Calculate depth of fragment for fog;
|
||||
// OpenGL 1.5 chapter 3.10: "An implementation may choose to approximate the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue