commit e3b4cfaed234d8bad4a4f23159258e5a6aca24e6 parent b4fdef2ce5c88b4d8cad66eb3f1808f107cbab64 Author: anon <anon@example.com> Date: Sun, 18 Oct 2026 20:35:23 +0000 Keep surface dimensions invariant during channel swaps Diffstat:
| M | src/runtime/linux_graphics.c | | | 7 | ++++--- |
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/runtime/linux_graphics.c b/src/runtime/linux_graphics.c @@ -1298,9 +1298,10 @@ static void surface_detach(void) static void swap_surface_channels(struct surface_object *surface) { unsigned char *pixels = (void *)ADDR(surface->pixels); - for (unsigned y = 0; y < surface->height; ++y) - for (unsigned x = 0; x < surface->width; ++x) { - size_t i = (size_t)y * surface->pitch + x * 4; + unsigned width = surface->width, height = surface->height, pitch = surface->pitch; + for (unsigned y = 0; y < height; ++y) + for (unsigned x = 0; x < width; ++x) { + size_t i = (size_t)y * pitch + x * 4; unsigned char red = pixels[i]; pixels[i] = pixels[i + 2]; pixels[i + 2] = red;