Cleanup
This commit is contained in:
parent
36fdb4596d
commit
f21f17f4c2
2 changed files with 22 additions and 20 deletions
|
@ -30,20 +30,20 @@ static void FlushSurface(Backend_Surface *surface)
|
|||
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_FreeSurface(Backend_Surface *surface)
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -146,16 +146,18 @@ void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Sur
|
|||
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
*destination_pointer++ = *source_pointer++;
|
||||
*destination_pointer++ = *source_pointer++;
|
||||
*destination_pointer++ = *source_pointer++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -219,13 +221,13 @@ void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned cha
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue