1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:07:36 +00:00

LibSoftGPU: Use memcpy instead of a loop to blit the color buffer

Looking at `Tubes` before and after this change, comparing the original
loop to the one using `memcpy`, including the time for `memcpy` itself,
resulted in ~15% fewer samples in profiles on my machine.
This commit is contained in:
Jelle Raaijmakers 2022-09-14 14:32:23 +02:00 committed by Andreas Kling
parent bfb4e08612
commit e9d2f9a95e

View file

@ -42,10 +42,7 @@ public:
for (int y = target.bottom(); y >= target.top(); --y) { for (int y = target.bottom(); y >= target.top(); --y) {
auto const* buffer_scanline = scanline(source_y++); auto const* buffer_scanline = scanline(source_y++);
auto* bitmap_scanline = bitmap.scanline(y); auto* bitmap_scanline = bitmap.scanline(y);
memcpy(bitmap_scanline + target.left(), buffer_scanline, sizeof(u32) * target.width());
int source_x = 0;
for (int x = target.left(); x <= target.right(); ++x)
bitmap_scanline[x] = buffer_scanline[source_x++];
} }
} }