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

Optimize the Painter::blit() loop a bit. ~3% fewer cycles, I'll take it.

This commit is contained in:
Andreas Kling 2019-01-16 19:43:01 +01:00
parent 7750e6952b
commit f651405694
4 changed files with 22 additions and 15 deletions

View file

@ -226,9 +226,15 @@ void Painter::blit(const Point& position, const GraphicsBitmap& source)
Rect dst_rect(position, source.size());
dst_rect.intersect(m_clip_rect);
for (int y = 0; y < dst_rect.height(); ++y) {
auto* dst_scanline = m_target->scanline(position.y() + y);
auto* src_scanline = source.scanline(y);
fast_dword_copy(dst_scanline + dst_rect.x(), src_scanline + (dst_rect.x() - position.x()), dst_rect.width());
RGBA32* dst = m_target->scanline(position.y()) + dst_rect.x();
const RGBA32* src= source.scanline(0) + (dst_rect.x() - position.x());
const unsigned dst_skip = m_target->width();
const unsigned src_skip = source.width();
for (int i = dst_rect.height() - 1; i >= 0; --i) {
fast_dword_copy(dst, src, dst_rect.width());
dst += dst_skip;
src += src_skip;
}
}