mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:37:34 +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
|
@ -29,7 +29,7 @@ public:
|
|||
return adopt_ref(*new Typed2DBuffer(buffer));
|
||||
}
|
||||
|
||||
void fill(T value, Gfx::IntRect const& rect) { m_buffer->fill(value, rect.left(), rect.right(), rect.top(), rect.bottom(), 0, 0); }
|
||||
void fill(T value, Gfx::IntRect const& rect) { m_buffer->fill(value, rect.left(), rect.right(), rect.top(), rect.bottom(), 0, 1); }
|
||||
ALWAYS_INLINE T* scanline(int y) { return m_buffer->buffer_pointer(0, y, 0); }
|
||||
ALWAYS_INLINE T const* scanline(int y) const { return m_buffer->buffer_pointer(0, y, 0); }
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
int source_y = 0;
|
||||
|
||||
// NOTE: we are flipping the Y-coordinate here, which is OpenGL-specific: (0, 0) is considered the lower-left corner of the window
|
||||
for (int y = target.bottom(); y >= target.top(); --y) {
|
||||
for (int y = target.bottom() - 1; y >= target.top(); --y) {
|
||||
auto const* buffer_scanline = scanline(source_y++);
|
||||
auto* bitmap_scanline = bitmap.scanline(y);
|
||||
memcpy(bitmap_scanline + target.left(), buffer_scanline, sizeof(u32) * target.width());
|
||||
|
|
|
@ -41,10 +41,10 @@ public:
|
|||
|
||||
void fill(T value, int x1, int x2, int y1, int y2, int z1, int z2)
|
||||
{
|
||||
for (auto z = z1; z <= z2; ++z) {
|
||||
for (auto y = y1; y <= y2; ++y) {
|
||||
for (auto z = z1; z < z2; ++z) {
|
||||
for (auto y = y1; y < y2; ++y) {
|
||||
auto* xline = buffer_pointer(0, y, z);
|
||||
for (auto x = x1; x <= x2; ++x)
|
||||
for (auto x = x1; x < x2; ++x)
|
||||
xline[x] = value;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue