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.
This commit is contained in:
Andreas Kling 2021-05-15 11:18:45 +02:00
parent da4928feea
commit 07850ccf51

View file

@ -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;