From 07850ccf5146c866a8d0899870662fb289832c61 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 15 May 2021 11:18:45 +0200 Subject: [PATCH] LibGfx: Fix incorrect origin for checkerboard pattern fills The checkerboard pattern used in transparency backgrounds was sometimes misaligned with the grid. This happened because it was incorrectly anchoring the pattern to the clipped rect instead of the global grid of the underlying paint target. --- Userland/Libraries/LibGfx/Painter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 5ec78c6e01..de6d51848c 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -178,9 +178,11 @@ void Painter::fill_rect_with_checkerboard(const IntRect& a_rect, const IntSize& const size_t dst_skip = m_target->pitch() / sizeof(RGBA32); for (int i = 0; i < rect.height(); ++i) { + int y = rect.y() + i; + int cell_row = y / cell_size.height(); for (int j = 0; j < rect.width(); ++j) { - int cell_row = i / cell_size.height(); - int cell_col = j / cell_size.width(); + int x = rect.x() + j; + int cell_col = x / cell_size.width(); dst[j] = ((cell_row % 2) ^ (cell_col % 2)) ? color_light.value() : color_dark.value(); } dst += dst_skip;