ref: f21f17f4c2fd8c4ba4d1fcf1dcf0976fd1d251ab
parent: 36fdb4596d2be7e3ae7a6749bc8f433f3a676864
author: Clownacy <Clownacy@users.noreply.github.com>
date: Wed Jul 17 10:13:49 EDT 2019
Cleanup
--- a/src/Backends/Rendering/SDLTexture.cpp
+++ b/src/Backends/Rendering/SDLTexture.cpp
@@ -30,20 +30,20 @@
unsigned char *buffer_pointer = buffer;
// Convert the SDL_Surface's colour-keyed pixels to RGBA32
- for (int h = 0; h < surface->sdl_surface->h; ++h)
+ for (int y = 0; y < surface->sdl_surface->h; ++y)
{
- unsigned char *src_pixel = (unsigned char*)surface->sdl_surface->pixels + (h * surface->sdl_surface->pitch);
+ unsigned char *src_pixel = (unsigned char*)surface->sdl_surface->pixels + (y * surface->sdl_surface->pitch);
- for (int w = 0; w < surface->sdl_surface->w; ++w)
+ for (int x = 0; x < surface->sdl_surface->x; ++x)
{
*buffer_pointer++ = src_pixel[0];
*buffer_pointer++ = src_pixel[1];
*buffer_pointer++ = src_pixel[2];
- if (src_pixel[0] != 0 || src_pixel[1] != 0 || src_pixel[2] != 0) // Assumes the colour key will always be #00000000 (black)
- *buffer_pointer++ = 0xFF;
- else
+ if (src_pixel[0] == 0 && src_pixel[1] == 0 && src_pixel[2] == 0) // Assumes the colour key will always be #000000 (black)
*buffer_pointer++ = 0;
+ else
+ *buffer_pointer++ = 0xFF;
src_pixel += 3;
}
@@ -148,10 +148,10 @@
void Backend_LoadPixels(Backend_Surface *surface, const unsigned char *pixels, unsigned int width, unsigned int height, unsigned int pitch)
{
- for (unsigned int h = 0; h < height; ++h)
+ for (unsigned int i = 0; i < height; ++i)
{
- const unsigned char *src_row = &pixels[h * pitch];
- unsigned char *dst_row = (unsigned char*)surface->sdl_surface->pixels + h * surface->sdl_surface->pitch;
+ const unsigned char *src_row = &pixels[i * pitch];
+ unsigned char *dst_row = (unsigned char*)surface->sdl_surface->pixels + i * surface->sdl_surface->pitch;
memcpy(dst_row, src_row, width * 3);
}
--- a/src/Backends/Rendering/Software.cpp
+++ b/src/Backends/Rendering/Software.cpp
@@ -146,15 +146,17 @@
for (long i = 0; i < rect_clamped.right - rect_clamped.left; ++i)
{
- if (source_pointer[0] != 0 || source_pointer[1] != 0 || source_pointer[2] != 0) // Assumes the colour key will always be #00000000 (black)
+ if (source_pointer[0] == 0 && source_pointer[1] == 0 && source_pointer[2] == 0) // Assumes the colour key will always be #000000 (black)
{
- destination_pointer[0] = source_pointer[0];
- destination_pointer[1] = source_pointer[1];
- destination_pointer[2] = source_pointer[2];
+ source_pointer += 3;
+ destination_pointer += 3;
}
-
- source_pointer += 3;
- destination_pointer += 3;
+ else
+ {
+ *destination_pointer++ = *source_pointer++;
+ *destination_pointer++ = *source_pointer++;
+ *destination_pointer++ = *source_pointer++;
+ }
}
}
}
@@ -219,13 +221,13 @@
for (long j = 0; j < rect_clamped.bottom - rect_clamped.top; ++j)
{
- unsigned char *source_pointer = &surface->pixels[((rect_clamped.top + j) * surface->pitch) + (rect_clamped.left * 3)];
+ unsigned char *destination_pointer = &surface->pixels[((rect_clamped.top + j) * surface->pitch) + (rect_clamped.left * 3)];
for (long i = 0; i < rect_clamped.right - rect_clamped.left; ++i)
{
- *source_pointer++ = red;
- *source_pointer++ = green;
- *source_pointer++ = blue;
+ *destination_pointer++ = red;
+ *destination_pointer++ = green;
+ *destination_pointer++ = blue;
}
}
}