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