1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:47:35 +00:00

LibGfx: Make draw_tiled_bitmap() in scaled contexts actually work

This commit is contained in:
Nico Weber 2021-01-22 18:53:09 -05:00 committed by Andreas Kling
parent d37efbe647
commit dcc967d1ad
2 changed files with 7 additions and 5 deletions

View file

@ -619,20 +619,20 @@ void Painter::draw_tiled_bitmap(const IntRect& a_dst_rect, const Gfx::Bitmap& so
if (source.format() == BitmapFormat::RGB32 || source.format() == BitmapFormat::RGBA32) {
int s = scale / source.scale();
if (s == 1) {
int x_start = first_column + a_dst_rect.left();
int x_start = first_column + a_dst_rect.left() * scale;
for (int row = first_row; row <= last_row; ++row) {
const RGBA32* sl = source.scanline((row + a_dst_rect.top()) % source.physical_height());
const RGBA32* sl = source.scanline((row + a_dst_rect.top() * scale) % source.physical_height());
for (int x = x_start; x < clipped_rect.width() + x_start; ++x) {
dst[x - x_start] = sl[x % source.physical_width()];
}
dst += dst_skip;
}
} else {
int x_start = first_column + a_dst_rect.left();
int x_start = first_column + a_dst_rect.left() * scale;
for (int row = first_row; row <= last_row; ++row) {
const RGBA32* sl = source.scanline(((row + a_dst_rect.top()) / s) % source.height());
const RGBA32* sl = source.scanline(((row + a_dst_rect.top() * scale) / s) % source.physical_height());
for (int x = x_start; x < clipped_rect.width() + x_start; ++x) {
dst[x - x_start] = sl[(x / s) % source.width()];
dst[x - x_start] = sl[(x / s) % source.physical_width()];
}
dst += dst_skip;
}