mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-08 17:04:24 +02:00
Cleaned up various type conversion issues
This makes sure SDL_PixelFormatEnum flows through the internal code correctly, as well as fixing a number of other minor issues.
This commit is contained in:
@@ -112,20 +112,17 @@ static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
||||
g = (Uint8)SDL_roundf(SDL_clamp(texture->color.g, 0.0f, 1.0f) * 255.0f);
|
||||
b = (Uint8)SDL_roundf(SDL_clamp(texture->color.b, 0.0f, 1.0f) * 255.0f);
|
||||
a = (Uint8)SDL_roundf(SDL_clamp(texture->color.a, 0.0f, 1.0f) * 255.0f);
|
||||
SDL_SetSurfaceColorMod(texture->driverdata, r, g, b);
|
||||
SDL_SetSurfaceAlphaMod(texture->driverdata, a);
|
||||
SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode);
|
||||
SDL_SetSurfaceColorMod(surface, r, g, b);
|
||||
SDL_SetSurfaceAlphaMod(surface, a);
|
||||
SDL_SetSurfaceBlendMode(surface, texture->blendMode);
|
||||
|
||||
/* Only RLE encode textures without an alpha channel since the RLE coder
|
||||
* discards the color values of pixels with an alpha value of zero.
|
||||
*/
|
||||
if (texture->access == SDL_TEXTUREACCESS_STATIC && !surface->format->Amask) {
|
||||
SDL_SetSurfaceRLE(texture->driverdata, 1);
|
||||
SDL_SetSurfaceRLE(surface, 1);
|
||||
}
|
||||
|
||||
if (!texture->driverdata) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1024,7 +1021,7 @@ static void SW_DestroyRenderer(SDL_Renderer *renderer)
|
||||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
static void SW_SelectBestFormats(SDL_Renderer *renderer, Uint32 format)
|
||||
static void SW_SelectBestFormats(SDL_Renderer *renderer, SDL_PixelFormatEnum format)
|
||||
{
|
||||
/* Prefer the format used by the framebuffer by default. */
|
||||
renderer->info.texture_formats[renderer->info.num_texture_formats++] = format;
|
||||
@@ -1080,6 +1077,8 @@ static void SW_SelectBestFormats(SDL_Renderer *renderer, Uint32 format)
|
||||
case SDL_PIXELFORMAT_BGRA8888:
|
||||
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_BGRX8888;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Ensure that we always have a SDL_PACKEDLAYOUT_8888 format. Having a matching component order increases the
|
||||
|
||||
@@ -278,7 +278,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
}
|
||||
|
||||
if (blend != SDL_BLENDMODE_NONE) {
|
||||
int format = dst->format->format;
|
||||
SDL_PixelFormatEnum format = dst->format->format;
|
||||
|
||||
/* need an alpha format */
|
||||
if (!dst->format->Amask) {
|
||||
@@ -300,7 +300,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
SDL_SetSurfaceBlendMode(tmp, blend);
|
||||
|
||||
dstbpp = tmp->format->bytes_per_pixel;
|
||||
dst_ptr = tmp->pixels;
|
||||
dst_ptr = (Uint8 *)tmp->pixels;
|
||||
dst_pitch = tmp->pitch;
|
||||
|
||||
} else {
|
||||
@@ -465,7 +465,7 @@ int SDL_SW_BlitTriangle(
|
||||
Uint8 *dst_ptr;
|
||||
int dst_pitch;
|
||||
|
||||
int *src_ptr;
|
||||
const int *src_ptr;
|
||||
int src_pitch;
|
||||
|
||||
Sint64 area, tmp64;
|
||||
@@ -583,7 +583,7 @@ int SDL_SW_BlitTriangle(
|
||||
dst_pitch = dst->pitch;
|
||||
|
||||
/* Set source pointer */
|
||||
src_ptr = src->pixels;
|
||||
src_ptr = (const int *)src->pixels;
|
||||
src_pitch = src->pitch;
|
||||
|
||||
is_clockwise = area > 0;
|
||||
|
||||
Reference in New Issue
Block a user