1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-26 01:55:08 +00:00

tiled backgrounds no longer has strange off-by-one pixel errors

This commit is contained in:
Christopher Dumas 2019-05-26 19:36:16 -07:00 committed by Andreas Kling
parent c23882dde1
commit aa50e5bb13
9 changed files with 346 additions and 16 deletions

View file

@ -279,25 +279,26 @@ void Painter::blit_tiled(const Point& position, const GraphicsBitmap& source, co
auto clipped_rect = dst_rect.intersected(clip_rect());
if (clipped_rect.is_empty())
return;
const int first_row = clipped_rect.top() - dst_rect.top();
const int last_row = clipped_rect.bottom() - dst_rect.top();
const int first_column = clipped_rect.left() - dst_rect.left();
const int last_column = clipped_rect.right() - dst_rect.left();
const int first_row = (clipped_rect.top() - dst_rect.top());
const int last_row = (clipped_rect.bottom() - dst_rect.top());
const int first_column = (clipped_rect.left() - dst_rect.left());
RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x();
const RGBA32* isrc = source.scanline(0) + src_rect.left() + first_column;
const RGBA32* src = source.scanline(src_rect.top() + first_row) + src_rect.left() + first_column;
const size_t dst_skip = m_target->pitch() / sizeof(RGBA32);
const size_t src_skip = source.pitch() / sizeof(RGBA32);
for (int row = first_row; row <= last_row; ++row) {
int y = (src - isrc) / src_skip % source.size().height();
src = y * src_skip + isrc;
for (int x = 0; x <= (last_column - first_column); ++x) {
dst[x] = src[x % source.size().width()];
if (source.format() == GraphicsBitmap::Format::RGB32 || source.format() == GraphicsBitmap::Format::RGBA32) {
int x_start = first_column + src_rect.left();
for (int row = first_row; row <= last_row; ++row) {
const RGBA32* sl = source.scanline((row + src_rect.top())
% source.size().height());
for (int x = x_start; x < clipped_rect.width() + x_start; ++x) {
dst[x - x_start] = sl[x % source.size().width()];
}
dst += dst_skip;
}
dst += dst_skip;
src += src_skip;
return;
}
ASSERT_NOT_REACHED();
}
void Painter::blit_with_alpha(const Point& position, const GraphicsBitmap& source, const Rect& src_rect)