From 073e62de46ffbaaf02dabe80b665161f43453efb Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 15 Apr 2020 16:57:05 +0100 Subject: [PATCH] Software renderer tweaks --- src/Backends/Rendering/Software.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Backends/Rendering/Software.cpp b/src/Backends/Rendering/Software.cpp index e86bdfa5..178c61ff 100644 --- a/src/Backends/Rendering/Software.cpp +++ b/src/Backends/Rendering/Software.cpp @@ -172,7 +172,7 @@ ATTRIBUTE_HOT void RenderBackend_Blit(RenderBackend_Surface *source_surface, con { for (long j = 0; j < rect_clamped.bottom - rect_clamped.top; ++j) { - unsigned char *source_pointer = &source_surface->pixels[((rect_clamped.top + j) * source_surface->pitch) + (rect_clamped.left * 3)]; + const unsigned char *source_pointer = &source_surface->pixels[((rect_clamped.top + j) * source_surface->pitch) + (rect_clamped.left * 3)]; unsigned char *destination_pointer = &destination_surface->pixels[((y + j) * destination_surface->pitch) + (x * 3)]; for (long i = 0; i < rect_clamped.right - rect_clamped.left; ++i) @@ -193,12 +193,15 @@ ATTRIBUTE_HOT void RenderBackend_Blit(RenderBackend_Surface *source_surface, con } else { + const unsigned char *source_pointer = &source_surface->pixels[(rect_clamped.top * source_surface->pitch) + (rect_clamped.left * 3)]; + unsigned char *destination_pointer = &destination_surface->pixels[(y * destination_surface->pitch) + (x * 3)]; + for (long j = 0; j < rect_clamped.bottom - rect_clamped.top; ++j) { - unsigned char *source_pointer = &source_surface->pixels[((rect_clamped.top + j) * source_surface->pitch) + (rect_clamped.left * 3)]; - unsigned char *destination_pointer = &destination_surface->pixels[((y + j) * destination_surface->pitch) + (x * 3)]; - memcpy(destination_pointer, source_pointer, (rect_clamped.right - rect_clamped.left) * 3); + + source_pointer += source_surface->pitch; + destination_pointer += destination_surface->pitch; } } }