Use C99 bool internally in SDL

This commit is contained in:
Sam Lantinga
2024-08-22 09:21:26 -07:00
parent 6501e90018
commit 8f546bb3c9
450 changed files with 6046 additions and 6033 deletions

View File

@@ -28,7 +28,7 @@
static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
bool draw_end)
{
const SDL_PixelFormatDetails *fmt = dst->internal->format;
unsigned r, g, b, a, inva;
@@ -151,7 +151,7 @@ static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2,
static void SDL_BlendLine_RGB555(SDL_Surface *dst, int x1, int y1, int x2, int y2,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
bool draw_end)
{
unsigned r, g, b, a, inva;
@@ -273,7 +273,7 @@ static void SDL_BlendLine_RGB555(SDL_Surface *dst, int x1, int y1, int x2, int y
static void SDL_BlendLine_RGB565(SDL_Surface *dst, int x1, int y1, int x2, int y2,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
bool draw_end)
{
unsigned r, g, b, a, inva;
@@ -395,7 +395,7 @@ static void SDL_BlendLine_RGB565(SDL_Surface *dst, int x1, int y1, int x2, int y
static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
bool draw_end)
{
const SDL_PixelFormatDetails *fmt = dst->internal->format;
unsigned r, g, b, a, inva;
@@ -518,7 +518,7 @@ static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2,
static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
bool draw_end)
{
const SDL_PixelFormatDetails *fmt = dst->internal->format;
unsigned r, g, b, a, inva;
@@ -641,7 +641,7 @@ static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2
static void SDL_BlendLine_XRGB8888(SDL_Surface *dst, int x1, int y1, int x2, int y2,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
bool draw_end)
{
unsigned r, g, b, a, inva;
@@ -763,7 +763,7 @@ static void SDL_BlendLine_XRGB8888(SDL_Surface *dst, int x1, int y1, int x2, int
static void SDL_BlendLine_ARGB8888(SDL_Surface *dst, int x1, int y1, int x2, int y2,
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
SDL_bool draw_end)
bool draw_end)
{
unsigned r, g, b, a, inva;
@@ -887,7 +887,7 @@ typedef void (*BlendLineFunc)(SDL_Surface *dst,
int x1, int y1, int x2, int y2,
SDL_BlendMode blendMode,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SDL_bool draw_end);
bool draw_end);
static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormatDetails *fmt)
{
@@ -939,7 +939,7 @@ int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2,
return 0;
}
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, SDL_TRUE);
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, true);
return 0;
}
@@ -949,7 +949,7 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
int i;
int x1, y1;
int x2, y2;
SDL_bool draw_end;
bool draw_end;
BlendLineFunc func;
if (!SDL_SurfaceValid(dst)) {

View File

@@ -27,7 +27,7 @@
#include "SDL_drawpoint.h"
static void SDL_DrawLine1(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color,
SDL_bool draw_end)
bool draw_end)
{
if (y1 == y2) {
int length;
@@ -54,7 +54,7 @@ static void SDL_DrawLine1(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint
}
static void SDL_DrawLine2(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color,
SDL_bool draw_end)
bool draw_end)
{
if (y1 == y2) {
HLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
@@ -83,7 +83,7 @@ static void SDL_DrawLine2(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint
}
static void SDL_DrawLine4(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color,
SDL_bool draw_end)
bool draw_end)
{
if (y1 == y2) {
HLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
@@ -115,7 +115,7 @@ static void SDL_DrawLine4(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint
typedef void (*DrawLineFunc)(SDL_Surface *dst,
int x1, int y1, int x2, int y2,
Uint32 color, SDL_bool draw_end);
Uint32 color, bool draw_end);
static DrawLineFunc SDL_CalculateDrawLineFunc(const SDL_PixelFormatDetails *fmt)
{
@@ -152,7 +152,7 @@ int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
return 0;
}
func(dst, x1, y1, x2, y2, color, SDL_TRUE);
func(dst, x1, y1, x2, y2, color, true);
return 0;
}
@@ -162,7 +162,7 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
int i;
int x1, y1;
int x2, y2;
SDL_bool draw_end;
bool draw_end;
DrawLineFunc func;
if (!SDL_SurfaceValid(dst)) {

View File

@@ -41,7 +41,7 @@ typedef struct
{
const SDL_Rect *viewport;
const SDL_Rect *cliprect;
SDL_bool surface_cliprect_dirty;
bool surface_cliprect_dirty;
SDL_Color color;
} SW_DrawStateCache;
@@ -326,9 +326,9 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
int retval = 0;
SDL_BlendMode blendmode;
Uint8 alphaMod, rMod, gMod, bMod;
int applyModulation = SDL_FALSE;
int blitRequired = SDL_FALSE;
int isOpaque = SDL_FALSE;
int applyModulation = false;
int blitRequired = false;
int isOpaque = false;
if (!SDL_SurfaceValid(surface)) {
return -1;
@@ -365,29 +365,29 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
// SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted.
if (src->internal->format->bits_per_pixel != 32 || SDL_PIXELLAYOUT(src->format) != SDL_PACKEDLAYOUT_8888 || !SDL_ISPIXELFORMAT_ALPHA(src->format)) {
blitRequired = SDL_TRUE;
blitRequired = true;
}
// If scaling and cropping is necessary, it has to be taken care of before the rotation.
if (!(srcrect->w == final_rect->w && srcrect->h == final_rect->h && srcrect->x == 0 && srcrect->y == 0)) {
blitRequired = SDL_TRUE;
blitRequired = true;
}
// srcrect is not selecting the whole src surface, so cropping is needed
if (!(srcrect->w == src->w && srcrect->h == src->h && srcrect->x == 0 && srcrect->y == 0)) {
blitRequired = SDL_TRUE;
blitRequired = true;
}
// The color and alpha modulation has to be applied before the rotation when using the NONE, MOD or MUL blend modes.
if ((blendmode == SDL_BLENDMODE_NONE || blendmode == SDL_BLENDMODE_MOD || blendmode == SDL_BLENDMODE_MUL) && (alphaMod & rMod & gMod & bMod) != 255) {
applyModulation = SDL_TRUE;
applyModulation = true;
SDL_SetSurfaceAlphaMod(src_clone, alphaMod);
SDL_SetSurfaceColorMod(src_clone, rMod, gMod, bMod);
}
// Opaque surfaces are much easier to handle with the NONE blend mode.
if (blendmode == SDL_BLENDMODE_NONE && !SDL_ISPIXELFORMAT_ALPHA(src->format) && alphaMod == 255) {
isOpaque = SDL_TRUE;
isOpaque = true;
}
/* The NONE blend mode requires a mask for non-opaque surfaces. This mask will be used
@@ -437,7 +437,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
if (!retval && mask) {
// The mask needed for the NONE blend mode gets rotated with the same parameters.
mask_rotated = SDLgfx_rotateSurface(mask, angle,
SDL_FALSE, 0, 0,
false, 0, 0,
&rect_dest, cangle, sangle, center);
if (!mask_rotated) {
retval = -1;
@@ -454,7 +454,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
* Other blend modes or opaque surfaces can be blitted directly.
*/
if (blendmode != SDL_BLENDMODE_NONE || isOpaque) {
if (applyModulation == SDL_FALSE) {
if (applyModulation == false) {
// If the modulation wasn't already applied, make it happen now.
SDL_SetSurfaceAlphaMod(src_rotated, alphaMod);
SDL_SetSurfaceColorMod(src_rotated, rMod, gMod, bMod);
@@ -629,9 +629,9 @@ static void PrepTextureForCopy(const SDL_RenderCommand *cmd, SW_DrawStateCache *
const SDL_BlendMode blend = cmd->data.draw.blend;
SDL_Texture *texture = cmd->data.draw.texture;
SDL_Surface *surface = (SDL_Surface *)texture->internal;
const SDL_bool colormod = ((r & g & b) != 0xFF);
const SDL_bool alphamod = (a != 0xFF);
const SDL_bool blending = ((blend == SDL_BLENDMODE_ADD) || (blend == SDL_BLENDMODE_MOD) || (blend == SDL_BLENDMODE_MUL));
const bool colormod = ((r & g & b) != 0xFF);
const bool alphamod = (a != 0xFF);
const bool blending = ((blend == SDL_BLENDMODE_ADD) || (blend == SDL_BLENDMODE_MOD) || (blend == SDL_BLENDMODE_MUL));
if (colormod || alphamod || blending) {
SDL_SetSurfaceRLE(surface, 0);
@@ -661,7 +661,7 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
} else {
SDL_SetSurfaceClipRect(surface, drawstate->viewport);
}
drawstate->surface_cliprect_dirty = SDL_FALSE;
drawstate->surface_cliprect_dirty = false;
}
}
@@ -682,7 +682,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
drawstate.viewport = NULL;
drawstate.cliprect = NULL;
drawstate.surface_cliprect_dirty = SDL_TRUE;
drawstate.surface_cliprect_dirty = true;
drawstate.color.r = 0;
drawstate.color.g = 0;
drawstate.color.b = 0;
@@ -702,14 +702,14 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
case SDL_RENDERCMD_SETVIEWPORT:
{
drawstate.viewport = &cmd->data.viewport.rect;
drawstate.surface_cliprect_dirty = SDL_TRUE;
drawstate.surface_cliprect_dirty = true;
break;
}
case SDL_RENDERCMD_SETCLIPRECT:
{
drawstate.cliprect = cmd->data.cliprect.enabled ? &cmd->data.cliprect.rect : NULL;
drawstate.surface_cliprect_dirty = SDL_TRUE;
drawstate.surface_cliprect_dirty = true;
break;
}
@@ -722,7 +722,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
// By definition the clear ignores the clip rect
SDL_SetSurfaceClipRect(surface, NULL);
SDL_FillSurfaceRect(surface, NULL, SDL_MapSurfaceRGBA(surface, r, g, b, a));
drawstate.surface_cliprect_dirty = SDL_TRUE;
drawstate.surface_cliprect_dirty = true;
break;
}
@@ -1120,7 +1120,7 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD
return SDL_InvalidParamError("surface");
}
renderer->software = SDL_TRUE;
renderer->software = true;
data = (SW_RenderData *)SDL_calloc(1, sizeof(*data));
if (!data) {
@@ -1171,7 +1171,7 @@ static int SW_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
{
// Set the vsync hint based on our flags, if it's not already set
const char *hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
const SDL_bool no_hint_set = (!hint || !*hint);
const bool no_hint_set = (!hint || !*hint);
if (no_hint_set) {
if (SDL_GetBooleanProperty(create_props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER, 0)) {

View File

@@ -492,7 +492,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
int is8bit, angle90;
SDL_BlendMode blendmode;
Uint32 colorkey = 0;
int colorKeyAvailable = SDL_FALSE;
int colorKeyAvailable = false;
double sangleinv, cangleinv;
// Sanity check
@@ -502,7 +502,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
if (SDL_SurfaceHasColorKey(src)) {
if (SDL_GetSurfaceColorKey(src, &colorkey) == 0) {
colorKeyAvailable = SDL_TRUE;
colorKeyAvailable = true;
}
}
// This function requires a 32-bit surface or 8-bit surface with a colorkey
@@ -538,9 +538,9 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
SDL_GetSurfaceBlendMode(src, &blendmode);
if (colorKeyAvailable == SDL_TRUE) {
if (colorKeyAvailable == true) {
// If available, the colorkey will be used to discard the pixels that are outside of the rotated area.
SDL_SetSurfaceColorKey(rz_dst, SDL_TRUE, colorkey);
SDL_SetSurfaceColorKey(rz_dst, true, colorkey);
SDL_FillSurfaceRect(rz_dst, NULL, colorkey);
} else if (blendmode == SDL_BLENDMODE_NONE) {
blendmode = SDL_BLENDMODE_BLEND;
@@ -554,7 +554,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
* all pixels outside of the rotated area. This doesn't interfere with anything because
* white pixels are already a no-op and the MOD blend mode does not interact with alpha.
*/
SDL_SetSurfaceColorKey(rz_dst, SDL_TRUE, colorkey);
SDL_SetSurfaceColorKey(rz_dst, true, colorkey);
}
SDL_SetSurfaceBlendMode(rz_dst, blendmode);

View File

@@ -42,7 +42,7 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
SDL_Color c0, SDL_Color c1, SDL_Color c2, SDL_bool is_uniform, SDL_TextureAddressMode texture_address_mode);
SDL_Color c0, SDL_Color c1, SDL_Color c2, bool is_uniform, SDL_TextureAddressMode texture_address_mode);
#if 0
int SDL_BlitTriangle(SDL_Surface *src, const SDL_Point srcpoints[3], SDL_Surface *dst, const SDL_Point dstpoints[3])
@@ -241,7 +241,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
Sint64 w0_row, w1_row, w2_row;
int bias_w0, bias_w1, bias_w2;
SDL_bool is_uniform;
bool is_uniform;
SDL_Surface *tmp = NULL;
@@ -494,9 +494,9 @@ int SDL_SW_BlitTriangle(
Sint64 w0_row, w1_row, w2_row;
int bias_w0, bias_w1, bias_w2;
SDL_bool is_uniform;
bool is_uniform;
SDL_bool has_modulation;
bool has_modulation;
if (!SDL_SurfaceValid(src)) {
return SDL_InvalidParamError("src");
@@ -573,7 +573,7 @@ int SDL_SW_BlitTriangle(
// SDL_GetSurfaceColorMod(src, &r, &g, &b);
has_modulation = c0.r != 255 || c0.g != 255 || c0.b != 255 || c0.a != 255;
} else {
has_modulation = SDL_TRUE;
has_modulation = true;
}
{
@@ -788,7 +788,7 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
SDL_Color c0, SDL_Color c1, SDL_Color c2, SDL_bool is_uniform, SDL_TextureAddressMode texture_address_mode)
SDL_Color c0, SDL_Color c1, SDL_Color c2, bool is_uniform, SDL_TextureAddressMode texture_address_mode)
{
SDL_Surface *src_surface = info->src_surface;
const int flags = info->flags;