mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-22 07:15:44 +00:00
Fixed warning C4127 (conditional expression is constant) in Visual Studio
This commit is contained in:
@@ -1093,7 +1093,6 @@ static void ChooseBestCameraSpec(SDL_Camera *device, const SDL_CameraSpec *spec,
|
||||
// that.
|
||||
|
||||
SDL_zerop(closest);
|
||||
SDL_assert(((Uint32) SDL_PIXELFORMAT_UNKNOWN) == 0); // since we SDL_zerop'd to this value.
|
||||
|
||||
if (device->num_specs == 0) { // device listed no specs! You get whatever you want!
|
||||
if (spec) {
|
||||
|
||||
@@ -2621,8 +2621,8 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C
|
||||
if (ctx->m_bReportSensors) {
|
||||
// Need to copy the imuState to an aligned variable
|
||||
SwitchControllerIMUState_t imuState[3];
|
||||
SDL_assert(sizeof(imuState) == sizeof(packet->imuState));
|
||||
SDL_memcpy(imuState, packet->imuState, sizeof(imuState));
|
||||
SDL_COMPILE_TIME_ASSERT(imuState_size, sizeof(imuState) == sizeof(packet->imuState));
|
||||
SDL_memcpy(imuState, packet->imuState, sizeof(packet->imuState));
|
||||
|
||||
bool bHasSensorData = (imuState[0].sAccelZ != 0 ||
|
||||
imuState[0].sAccelY != 0 ||
|
||||
|
||||
@@ -170,13 +170,24 @@
|
||||
/*
|
||||
* The general slow catch-all function, for remaining depths and formats
|
||||
*/
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
#define SET_RGB24(dst, d) \
|
||||
dst[0] = (Uint8)(d >> 16); \
|
||||
dst[1] = (Uint8)(d >> 8); \
|
||||
dst[2] = (Uint8)(d);
|
||||
#else
|
||||
#define SET_RGB24(dst, d) \
|
||||
dst[0] = (Uint8)(d); \
|
||||
dst[1] = (Uint8)(d >> 8); \
|
||||
dst[2] = (Uint8)(d >> 16);
|
||||
#endif
|
||||
#define ALPHA_BLIT_ANY(to, from, length, bpp, alpha) \
|
||||
do { \
|
||||
int i; \
|
||||
Uint8 *src = from; \
|
||||
Uint8 *dst = to; \
|
||||
for (i = 0; i < (int)(length); i++) { \
|
||||
Uint32 s = 0, d = 0; \
|
||||
Uint32 s = 0, d = 0; \
|
||||
unsigned rs, gs, bs, rd, gd, bd; \
|
||||
switch (bpp) { \
|
||||
case 2: \
|
||||
@@ -184,13 +195,8 @@
|
||||
d = *(Uint16 *)dst; \
|
||||
break; \
|
||||
case 3: \
|
||||
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
|
||||
s = (src[0] << 16) | (src[1] << 8) | src[2]; \
|
||||
d = (dst[0] << 16) | (dst[1] << 8) | dst[2]; \
|
||||
} else { \
|
||||
s = (src[2] << 16) | (src[1] << 8) | src[0]; \
|
||||
d = (dst[2] << 16) | (dst[1] << 8) | dst[0]; \
|
||||
} \
|
||||
s = GET_RGB24(src); \
|
||||
d = GET_RGB24(dst); \
|
||||
break; \
|
||||
case 4: \
|
||||
s = *(Uint32 *)src; \
|
||||
@@ -208,15 +214,7 @@
|
||||
*(Uint16 *)dst = (Uint16)d; \
|
||||
break; \
|
||||
case 3: \
|
||||
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
|
||||
dst[0] = (Uint8)(d >> 16); \
|
||||
dst[1] = (Uint8)(d >> 8); \
|
||||
dst[2] = (Uint8)(d); \
|
||||
} else { \
|
||||
dst[0] = (Uint8)d; \
|
||||
dst[1] = (Uint8)(d >> 8); \
|
||||
dst[2] = (Uint8)(d >> 16); \
|
||||
} \
|
||||
SET_RGB24(dst, d); \
|
||||
break; \
|
||||
case 4: \
|
||||
*(Uint32 *)dst = d; \
|
||||
@@ -649,7 +647,8 @@ static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst,
|
||||
return; \
|
||||
} while (ofs < w); \
|
||||
/* skip padding if necessary */ \
|
||||
if (sizeof(Ptype) == 2) \
|
||||
const size_t psize = sizeof(Ptype); \
|
||||
if (psize == 2) \
|
||||
srcbuf += (uintptr_t)srcbuf & 2; \
|
||||
/* blit translucent pixels on the same line */ \
|
||||
ofs = 0; \
|
||||
@@ -806,7 +805,8 @@ static bool SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcr
|
||||
goto done; \
|
||||
} while (ofs < w); \
|
||||
/* skip padding if necessary */ \
|
||||
if (sizeof(Ptype) == 2) \
|
||||
const size_t psize = sizeof(Ptype); \
|
||||
if (psize == 2) \
|
||||
srcbuf += (uintptr_t)srcbuf & 2; \
|
||||
/* blit translucent pixels on the same line */ \
|
||||
ofs = 0; \
|
||||
|
||||
@@ -150,6 +150,11 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
|
||||
g = ((Pixel & 0xFF00) >> 8); \
|
||||
b = (Pixel & 0xFF); \
|
||||
}
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
#define GET_RGB24(B) (B[2] << 16) | (B[1] << 8) | B[0]
|
||||
#else
|
||||
#define GET_RGB24(B) (B[0] << 16) | (B[1] << 8) | B[2]
|
||||
#endif
|
||||
#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel) \
|
||||
do { \
|
||||
switch (bpp) { \
|
||||
@@ -164,11 +169,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
|
||||
case 3: \
|
||||
{ \
|
||||
Uint8 *B = (Uint8 *)(buf); \
|
||||
if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
|
||||
Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
|
||||
} else { \
|
||||
Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
|
||||
} \
|
||||
Pixel = GET_RGB24(B); \
|
||||
} break; \
|
||||
\
|
||||
case 4: \
|
||||
@@ -181,44 +182,43 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \
|
||||
do { \
|
||||
switch (bpp) { \
|
||||
case 1: \
|
||||
Pixel = *((Uint8 *)(buf)); \
|
||||
RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
|
||||
break; \
|
||||
\
|
||||
case 2: \
|
||||
Pixel = *((Uint16 *)(buf)); \
|
||||
RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
|
||||
break; \
|
||||
\
|
||||
case 3: \
|
||||
{ \
|
||||
Pixel = 0; \
|
||||
if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
|
||||
r = *((buf) + fmt->Rshift / 8); \
|
||||
g = *((buf) + fmt->Gshift / 8); \
|
||||
b = *((buf) + fmt->Bshift / 8); \
|
||||
} else { \
|
||||
r = *((buf) + 2 - fmt->Rshift / 8); \
|
||||
g = *((buf) + 2 - fmt->Gshift / 8); \
|
||||
b = *((buf) + 2 - fmt->Bshift / 8); \
|
||||
} \
|
||||
} break; \
|
||||
\
|
||||
case 4: \
|
||||
Pixel = *((Uint32 *)(buf)); \
|
||||
RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
|
||||
break; \
|
||||
\
|
||||
default: \
|
||||
/* stop gcc complaints */ \
|
||||
Pixel = 0; \
|
||||
r = g = b = 0; \
|
||||
break; \
|
||||
} \
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
#define GET_RGB24_COMPONENT(buf, fmt, shift) *((buf) + fmt->shift / 8)
|
||||
#else
|
||||
#define GET_RGB24_COMPONENT(buf, fmt, shift) *((buf) + 2 - fmt->shift / 8)
|
||||
#endif
|
||||
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \
|
||||
do { \
|
||||
switch (bpp) { \
|
||||
case 1: \
|
||||
Pixel = *((Uint8 *)(buf)); \
|
||||
RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
|
||||
break; \
|
||||
\
|
||||
case 2: \
|
||||
Pixel = *((Uint16 *)(buf)); \
|
||||
RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
|
||||
break; \
|
||||
\
|
||||
case 3: \
|
||||
{ \
|
||||
Pixel = 0; \
|
||||
r = GET_RGB24_COMPONENT(buf, fmt, Rshift); \
|
||||
g = GET_RGB24_COMPONENT(buf, fmt, Gshift); \
|
||||
b = GET_RGB24_COMPONENT(buf, fmt, Bshift); \
|
||||
} break; \
|
||||
\
|
||||
case 4: \
|
||||
Pixel = *((Uint32 *)(buf)); \
|
||||
RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
|
||||
break; \
|
||||
\
|
||||
default: \
|
||||
/* stop gcc complaints */ \
|
||||
Pixel = 0; \
|
||||
r = g = b = 0; \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Assemble R-G-B values into a specified pixel format and store them
|
||||
@@ -299,46 +299,40 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
|
||||
(((Uint32)SDL_roundf(g)) << 10) | \
|
||||
(Uint32)SDL_roundf(r); \
|
||||
}
|
||||
#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \
|
||||
{ \
|
||||
switch (bpp) { \
|
||||
case 1: \
|
||||
{ \
|
||||
Uint8 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \
|
||||
*((Uint8 *)(buf)) = _pixel; \
|
||||
} break; \
|
||||
\
|
||||
case 2: \
|
||||
{ \
|
||||
Uint16 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \
|
||||
*((Uint16 *)(buf)) = _pixel; \
|
||||
} break; \
|
||||
\
|
||||
case 3: \
|
||||
{ \
|
||||
if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
|
||||
*((buf) + fmt->Rshift / 8) = r; \
|
||||
*((buf) + fmt->Gshift / 8) = g; \
|
||||
*((buf) + fmt->Bshift / 8) = b; \
|
||||
} else { \
|
||||
*((buf) + 2 - fmt->Rshift / 8) = r; \
|
||||
*((buf) + 2 - fmt->Gshift / 8) = g; \
|
||||
*((buf) + 2 - fmt->Bshift / 8) = b; \
|
||||
} \
|
||||
} break; \
|
||||
\
|
||||
case 4: \
|
||||
{ \
|
||||
Uint32 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \
|
||||
*((Uint32 *)(buf)) = _pixel; \
|
||||
} break; \
|
||||
} \
|
||||
#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \
|
||||
{ \
|
||||
switch (bpp) { \
|
||||
case 1: \
|
||||
{ \
|
||||
Uint8 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \
|
||||
*((Uint8 *)(buf)) = _pixel; \
|
||||
} break; \
|
||||
\
|
||||
case 2: \
|
||||
{ \
|
||||
Uint16 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \
|
||||
*((Uint16 *)(buf)) = _pixel; \
|
||||
} break; \
|
||||
\
|
||||
case 3: \
|
||||
{ \
|
||||
GET_RGB24_COMPONENT(buf, fmt, Rshift) = r; \
|
||||
GET_RGB24_COMPONENT(buf, fmt, Gshift) = g; \
|
||||
GET_RGB24_COMPONENT(buf, fmt, Bshift) = b; \
|
||||
} break; \
|
||||
\
|
||||
case 4: \
|
||||
{ \
|
||||
Uint32 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \
|
||||
*((Uint32 *)(buf)) = _pixel; \
|
||||
} break; \
|
||||
} \
|
||||
}
|
||||
|
||||
// FIXME: Should we rescale alpha into 0..255 here?
|
||||
@@ -428,15 +422,9 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
|
||||
case 3: \
|
||||
{ \
|
||||
Pixel = 0; \
|
||||
if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
|
||||
r = *((buf) + fmt->Rshift / 8); \
|
||||
g = *((buf) + fmt->Gshift / 8); \
|
||||
b = *((buf) + fmt->Bshift / 8); \
|
||||
} else { \
|
||||
r = *((buf) + 2 - fmt->Rshift / 8); \
|
||||
g = *((buf) + 2 - fmt->Gshift / 8); \
|
||||
b = *((buf) + 2 - fmt->Bshift / 8); \
|
||||
} \
|
||||
r = GET_RGB24_COMPONENT(buf, fmt, Rshift); \
|
||||
g = GET_RGB24_COMPONENT(buf, fmt, Gshift); \
|
||||
b = GET_RGB24_COMPONENT(buf, fmt, Bshift); \
|
||||
a = 0xFF; \
|
||||
} break; \
|
||||
\
|
||||
@@ -461,46 +449,40 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
|
||||
((b >> (8 - fmt->Bbits)) << fmt->Bshift) | \
|
||||
((a >> (8 - fmt->Abits)) << fmt->Ashift); \
|
||||
}
|
||||
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \
|
||||
{ \
|
||||
switch (bpp) { \
|
||||
case 1: \
|
||||
{ \
|
||||
Uint8 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \
|
||||
*((Uint8 *)(buf)) = _pixel; \
|
||||
} break; \
|
||||
\
|
||||
case 2: \
|
||||
{ \
|
||||
Uint16 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \
|
||||
*((Uint16 *)(buf)) = _pixel; \
|
||||
} break; \
|
||||
\
|
||||
case 3: \
|
||||
{ \
|
||||
if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
|
||||
*((buf) + fmt->Rshift / 8) = r; \
|
||||
*((buf) + fmt->Gshift / 8) = g; \
|
||||
*((buf) + fmt->Bshift / 8) = b; \
|
||||
} else { \
|
||||
*((buf) + 2 - fmt->Rshift / 8) = r; \
|
||||
*((buf) + 2 - fmt->Gshift / 8) = g; \
|
||||
*((buf) + 2 - fmt->Bshift / 8) = b; \
|
||||
} \
|
||||
} break; \
|
||||
\
|
||||
case 4: \
|
||||
{ \
|
||||
Uint32 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \
|
||||
*((Uint32 *)(buf)) = _pixel; \
|
||||
} break; \
|
||||
} \
|
||||
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \
|
||||
{ \
|
||||
switch (bpp) { \
|
||||
case 1: \
|
||||
{ \
|
||||
Uint8 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \
|
||||
*((Uint8 *)(buf)) = _pixel; \
|
||||
} break; \
|
||||
\
|
||||
case 2: \
|
||||
{ \
|
||||
Uint16 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \
|
||||
*((Uint16 *)(buf)) = _pixel; \
|
||||
} break; \
|
||||
\
|
||||
case 3: \
|
||||
{ \
|
||||
GET_RGB24_COMPONENT(buf, fmt, Rshift) = r; \
|
||||
GET_RGB24_COMPONENT(buf, fmt, Gshift) = g; \
|
||||
GET_RGB24_COMPONENT(buf, fmt, Bshift) = b; \
|
||||
} break; \
|
||||
\
|
||||
case 4: \
|
||||
{ \
|
||||
Uint32 _pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \
|
||||
*((Uint32 *)(buf)) = _pixel; \
|
||||
} break; \
|
||||
} \
|
||||
}
|
||||
|
||||
// Convert any 32-bit 4-bpp pixel to ARGB format
|
||||
|
||||
@@ -180,7 +180,8 @@ void STD_FUNCTION_NAME(
|
||||
}
|
||||
|
||||
/* Catch the last pixel, if needed */
|
||||
if (uv_x_sample_interval == 2 && x == (width-1))
|
||||
#if uv_x_sample_interval == 2
|
||||
if (x == (width-1))
|
||||
{
|
||||
// Compute U and V contributions, common to the four pixels
|
||||
|
||||
@@ -201,10 +202,12 @@ void STD_FUNCTION_NAME(
|
||||
PACK_PIXEL(rgb_ptr2);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Catch the last line, if needed */
|
||||
if (uv_y_sample_interval == 2 && y == (height-1))
|
||||
#if uv_y_sample_interval == 2
|
||||
if (y == (height-1))
|
||||
{
|
||||
const YUV_TYPE *y_ptr1=Y+y*Y_stride,
|
||||
*u_ptr=U+(y/uv_y_sample_interval)*UV_stride,
|
||||
@@ -237,7 +240,8 @@ void STD_FUNCTION_NAME(
|
||||
}
|
||||
|
||||
/* Catch the last pixel, if needed */
|
||||
if (uv_x_sample_interval == 2 && x == (width-1))
|
||||
#if uv_x_sample_interval == 2
|
||||
if (x == (width-1))
|
||||
{
|
||||
// Compute U and V contributions, common to the four pixels
|
||||
|
||||
@@ -253,7 +257,9 @@ void STD_FUNCTION_NAME(
|
||||
int32_t y_tmp = (GET(y_ptr1[0]-param->y_shift)*param->y_factor);
|
||||
PACK_PIXEL(rgb_ptr1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef y_pixel_stride
|
||||
#undef uv_pixel_stride
|
||||
|
||||
Reference in New Issue
Block a user