From 8630fd20ad7de0cc896b3d2c8c7aac80a62a1262 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 11 Nov 2023 09:07:00 +1100 Subject: [PATCH] [common] rects: simplify unaligned copy function --- common/include/common/rects.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/include/common/rects.h b/common/include/common/rects.h index 9d2dbeed..b238c711 100644 --- a/common/include/common/rects.h +++ b/common/include/common/rects.h @@ -27,15 +27,17 @@ #include "common/framebuffer.h" #include "common/types.h" -inline static void rectCopyUnaligned(uint8_t * dest, const uint8_t * src, +inline static void rectCopyUnaligned(uint8_t * dst, const uint8_t * src, int ystart, int yend, int dx, int dstPitch, int srcPitch, int width) { + src += ystart * srcPitch + dx; + dst += ystart * dstPitch + dx; for (int i = ystart; i < yend; ++i) { - unsigned int srcOffset = i * srcPitch + dx; - unsigned int dstOffset = i * dstPitch + dx; - memcpy(dest + dstOffset, src + srcOffset, width); - } + memcpy(dst, src, width); + src += srcPitch; + dst += dstPitch; + } } void rectsBufferToFramebuffer(FrameDamageRect * rects, int count, int bpp,