diff options
author | Tim Ledbetter <timledbetter@gmail.com> | 2023-02-03 17:11:59 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-08 21:53:34 +0100 |
commit | 392dac08187cbaadce4a9f54f684619622666603 (patch) | |
tree | d7e5a29a0dff81b8e288172b32de402ff0336125 /Userland/Libraries/LibGfx | |
parent | b0db56cd39e20035d426bb30a6e7bd76318bebee (diff) | |
download | serenity-392dac08187cbaadce4a9f54f684619622666603.zip |
LibGfx: Make checkerboard patterns static when panning
Previously checkerboard patterns were anchored to the top left of the
bitmap they were being drawn into.
This makes the transparency grid in PixelPaint static relative to the
canvas when panning.
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r-- | Userland/Libraries/LibGfx/Painter.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 72340378b4..faaa537292 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -197,19 +197,20 @@ void Painter::fill_rect_with_checkerboard(IntRect const& a_rect, IntSize cell_si { VERIFY(scale() == 1); // FIXME: Add scaling support. - auto rect = a_rect.translated(translation()).intersected(clip_rect()); + auto translated_rect = a_rect.translated(translation()); + auto rect = translated_rect.intersected(clip_rect()); if (rect.is_empty()) return; ARGB32* dst = m_target->scanline(rect.top()) + rect.left(); size_t const dst_skip = m_target->pitch() / sizeof(ARGB32); - int first_cell_column = rect.x() / cell_size.width(); - int prologue_length = min(rect.width(), cell_size.width() - (rect.x() % cell_size.width())); + int first_cell_column = (rect.x() - translated_rect.x()) / cell_size.width(); + int prologue_length = min(rect.width(), cell_size.width() - ((rect.x() - translated_rect.x()) % cell_size.width())); int number_of_aligned_strips = (rect.width() - prologue_length) / cell_size.width(); for (int i = 0; i < rect.height(); ++i) { - int y = rect.y() + i; + int y = rect.y() - translated_rect.y() + i; int cell_row = y / cell_size.height(); bool odd_row = cell_row & 1; |