Fixed Visual Studio warning 4244

This commit is contained in:
Sam Lantinga
2023-03-30 14:04:32 -07:00
parent 85ee1498a5
commit 308bcbbe76
29 changed files with 160 additions and 155 deletions

View File

@@ -1111,20 +1111,20 @@ static int RLEAlphaSurface(SDL_Surface *surface)
Uint8 *lastline = dst; /* end of last non-blank line */
/* opaque counts are 8 or 16 bits, depending on target depth */
#define ADD_OPAQUE_COUNTS(n, m) \
if (df->BytesPerPixel == 4) { \
((Uint16 *)dst)[0] = n; \
((Uint16 *)dst)[1] = m; \
dst += 4; \
} else { \
dst[0] = n; \
dst[1] = m; \
dst += 2; \
#define ADD_OPAQUE_COUNTS(n, m) \
if (df->BytesPerPixel == 4) { \
((Uint16 *)dst)[0] = (Uint16)n; \
((Uint16 *)dst)[1] = (Uint16)m; \
dst += 4; \
} else { \
dst[0] = (Uint8)n; \
dst[1] = (Uint8)m; \
dst += 2; \
}
/* translucent counts are always 16 bit */
#define ADD_TRANSL_COUNTS(n, m) \
(((Uint16 *)dst)[0] = n, ((Uint16 *)dst)[1] = m, dst += 4)
(((Uint16 *)dst)[0] = (Uint16)n, ((Uint16 *)dst)[1] = (Uint16)m, dst += 4)
for (y = 0; y < h; y++) {
int runstart, skipstart;
@@ -1314,15 +1314,15 @@ static int RLEColorkeySurface(SDL_Surface *surface)
w = surface->w;
h = surface->h;
#define ADD_COUNTS(n, m) \
if (bpp == 4) { \
((Uint16 *)dst)[0] = n; \
((Uint16 *)dst)[1] = m; \
dst += 4; \
} else { \
dst[0] = n; \
dst[1] = m; \
dst += 2; \
#define ADD_COUNTS(n, m) \
if (bpp == 4) { \
((Uint16 *)dst)[0] = (Uint16)n; \
((Uint16 *)dst)[1] = (Uint16)m; \
dst += 4; \
} else { \
dst[0] = (Uint8)n; \
dst[1] = (Uint8)m; \
dst += 2; \
}
for (y = 0; y < h; y++) {

View File

@@ -226,11 +226,11 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
}
#define RGB565_FROM_RGB(Pixel, r, g, b) \
{ \
Pixel = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); \
Pixel = (Uint16)(((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)); \
}
#define RGB555_FROM_RGB(Pixel, r, g, b) \
{ \
Pixel = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3); \
Pixel = (Uint16)(((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3)); \
}
#define RGB888_FROM_RGB(Pixel, r, g, b) \
{ \
@@ -574,9 +574,8 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
#endif /* USE_DUFFS_LOOP */
/* Prevent Visual C++ 6.0 from printing out stupid warnings */
#if defined(_MSC_VER) && (_MSC_VER >= 600)
#pragma warning(disable : 4550)
#pragma warning(disable : 4244) /* '=': conversion from 'X' to 'Y', possible loss of data */
#endif
#endif /* SDL_blit_h_ */

View File

@@ -492,7 +492,7 @@ static void Blit1toNAlphaKey(SDL_BlitInfo *info)
sB = srcpal[*src].b;
DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
}
src++;
dst += dstbpp;

View File

@@ -58,7 +58,7 @@ static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info)
dB &= 0xff;
/* Pack RGB into 8bit pixel */
if ( palmap == NULL ) {
*dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0));
*dst = (Uint8)(((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0)));
} else {
*dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))];
}
@@ -103,7 +103,7 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info)
dB &= 0xff;
/* Pack RGB into 8bit pixel */
if ( palmap == NULL ) {
*dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0));
*dst = (Uint8)(((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0)));
} else {
*dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))];
}
@@ -151,7 +151,7 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info)
dB &= 0xff;
/* Pack RGB into 8bit pixel */
if ( palmap == NULL ) {
*dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0));
*dst = (Uint8)(((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0)));
} else {
*dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))];
}

View File

@@ -2117,9 +2117,7 @@ static void BlitNto1(SDL_BlitInfo *info)
sR, sG, sB);
if ( 1 ) {
/* Pack RGB into 8bit pixel */
*dst = ((sR>>5)<<(3+2))|
((sG>>5)<<(2)) |
((sB>>6)<<(0)) ;
*dst = (Uint8)(((sR>>5)<<(3+2)) | ((sG>>5)<<(2)) | ((sB>>6)<<(0)));
}
dst++;
src += srcbpp;
@@ -2343,7 +2341,7 @@ static void BlitNtoN(SDL_BlitInfo *info)
dst[1] = src[p1];
dst[2] = src[p2];
dst[3] = src[p3];
dst[alpha_channel] = alpha;
dst[alpha_channel] = (Uint8)alpha;
src += 4;
dst += 4;
}, width);
@@ -2397,7 +2395,7 @@ static void BlitNtoN(SDL_BlitInfo *info)
dst[1] = src[p1];
dst[2] = src[p2];
dst[3] = src[p3];
dst[alpha_channel] = alpha;
dst[alpha_channel] = (Uint8)alpha;
src += 3;
dst += 4;
}, width);
@@ -2670,7 +2668,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info)
dst[1] = src[p1];
dst[2] = src[p2];
dst[3] = src[p3];
dst[alpha_channel] = alpha;
dst[alpha_channel] = (Uint8)alpha;
}
src += 4;
dst += 4;
@@ -2819,7 +2817,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info)
dst[1] = src[p1];
dst[2] = src[p2];
dst[3] = src[p3];
dst[alpha_channel] = alpha;
dst[alpha_channel] = (Uint8)alpha;
}
src += 3;
dst += 4;

View File

@@ -565,8 +565,8 @@ int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
/* Set up the format */
SDL_zerop(format);
format->format = pixel_format;
format->BitsPerPixel = bpp;
format->BytesPerPixel = (bpp + 7) / 8;
format->BitsPerPixel = (Uint8)bpp;
format->BytesPerPixel = (Uint8)((bpp + 7) / 8);
format->Rmask = Rmask;
format->Rshift = 0;
@@ -772,14 +772,14 @@ void SDL_DitherColors(SDL_Color *colors, int bpp)
so 0 is mapped to (0, 0, 0) and 255 to (255, 255, 255) */
r = i & 0xe0;
r |= r >> 3 | r >> 6;
colors[i].r = r;
colors[i].r = (Uint8)r;
g = (i << 3) & 0xe0;
g |= g >> 3 | g >> 6;
colors[i].g = g;
colors[i].g = (Uint8)g;
b = i & 0x3;
b |= b << 2;
b |= b << 4;
colors[i].b = b;
colors[i].b = (Uint8)b;
colors[i].a = SDL_ALPHA_OPAQUE;
}
}
@@ -804,7 +804,7 @@ Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
ad = pal->colors[i].a - a;
distance = (rd * rd) + (gd * gd) + (bd * bd) + (ad * ad);
if (distance < smallest) {
pixel = i;
pixel = (Uint8)i;
if (distance == 0) { /* Perfect match! */
break;
}

View File

@@ -263,10 +263,10 @@ static SDL_INLINE void INTERPOL(const Uint32 *src_x0, const Uint32 *src_x1, int
cx->c = c0->c + INTEGER(frac0 * (c1->c - c0->c));
cx->d = c0->d + INTEGER(frac0 * (c1->d - c0->d));
#else
cx->a = INTEGER(frac1 * c0->a + frac0 * c1->a);
cx->b = INTEGER(frac1 * c0->b + frac0 * c1->b);
cx->c = INTEGER(frac1 * c0->c + frac0 * c1->c);
cx->d = INTEGER(frac1 * c0->d + frac0 * c1->d);
cx->a = (Uint8)INTEGER(frac1 * c0->a + frac0 * c1->a);
cx->b = (Uint8)INTEGER(frac1 * c0->b + frac0 * c1->b);
cx->c = (Uint8)INTEGER(frac1 * c0->c + frac0 * c1->c);
cx->d = (Uint8)INTEGER(frac1 * c0->d + frac0 * c1->d);
#endif
}
@@ -375,7 +375,7 @@ static SDL_INLINE void SDL_TARGETING("sse2") INTERPOL_BILINEAR_SSE(const Uint32
int f, f2;
f = frac_w;
f2 = FRAC_ONE - frac_w;
v_frac_w0 = _mm_set_epi16(f, f2, f, f2, f, f2, f, f2);
v_frac_w0 = _mm_set_epi16((short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2);
x_00_01 = _mm_loadl_epi64((const __m128i *)s0); /* Load x00 and x01 */
x_10_11 = _mm_loadl_epi64((const __m128i *)s1);
@@ -418,8 +418,8 @@ static int SDL_TARGETING("sse2") scale_mat_SSE(const Uint32 *src, int src_w, int
nb_block2 = middle / 2;
v_frac_h0 = _mm_set_epi16(frac_h0, frac_h0, frac_h0, frac_h0, frac_h0, frac_h0, frac_h0, frac_h0);
v_frac_h1 = _mm_set_epi16(frac_h1, frac_h1, frac_h1, frac_h1, frac_h1, frac_h1, frac_h1, frac_h1);
v_frac_h0 = _mm_set_epi16((short)frac_h0, (short)frac_h0, (short)frac_h0, (short)frac_h0, (short)frac_h0, (short)frac_h0, (short)frac_h0, (short)frac_h0);
v_frac_h1 = _mm_set_epi16((short)frac_h1, (short)frac_h1, (short)frac_h1, (short)frac_h1, (short)frac_h1, (short)frac_h1, (short)frac_h1, (short)frac_h1);
zero = _mm_setzero_si128();
while (left_pad_w--) {
@@ -460,11 +460,11 @@ static int SDL_TARGETING("sse2") scale_mat_SSE(const Uint32 *src, int src_w, int
f = frac_w_0;
f2 = FRAC_ONE - frac_w_0;
v_frac_w0 = _mm_set_epi16(f, f2, f, f2, f, f2, f, f2);
v_frac_w0 = _mm_set_epi16((short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2);
f = frac_w_1;
f2 = FRAC_ONE - frac_w_1;
v_frac_w1 = _mm_set_epi16(f, f2, f, f2, f, f2, f, f2);
v_frac_w1 = _mm_set_epi16((short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2);
x_00_01 = _mm_loadl_epi64((const __m128i *)s_00_01); /* Load x00 and x01 */
x_02_03 = _mm_loadl_epi64((const __m128i *)s_02_03);

View File

@@ -1105,7 +1105,7 @@ SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *format)
SDL_Rect bounds;
int ret;
SDL_bool palette_ck_transform = SDL_FALSE;
int palette_ck_value = 0;
Uint8 palette_ck_value = 0;
SDL_bool palette_has_alpha = SDL_FALSE;
Uint8 *palette_saved_alpha = NULL;
int palette_saved_alpha_ncolors = 0;

View File

@@ -414,8 +414,8 @@ static void Vec2ToDLU(short *x, short *y)
{
SDL_assert(s_BaseUnitsX != 0); /* we init in WIN_ShowMessageBox(), which is the only public function... */
*x = MulDiv(*x, 4, s_BaseUnitsX);
*y = MulDiv(*y, 8, s_BaseUnitsY);
*x = (short)MulDiv(*x, 4, s_BaseUnitsX);
*y = (short)MulDiv(*y, 8, s_BaseUnitsY);
}
static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, DWORD exStyle, int x, int y, int w, int h, int id, const char *caption, WORD ordinal)
@@ -427,10 +427,10 @@ static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style,
SDL_zero(item);
item.style = style;
item.exStyle = exStyle;
item.x = x;
item.y = y;
item.cx = w;
item.cy = h;
item.x = (short)x;
item.y = (short)y;
item.cx = (short)w;
item.cy = (short)h;
item.id = id;
Vec2ToDLU(&item.x, &item.y);
@@ -516,8 +516,8 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption)
dialogTemplate.style = (WS_CAPTION | DS_CENTER | DS_SHELLFONT);
dialogTemplate.x = 0;
dialogTemplate.y = 0;
dialogTemplate.cx = w;
dialogTemplate.cy = h;
dialogTemplate.cx = (short)w;
dialogTemplate.cy = (short)h;
Vec2ToDLU(&dialogTemplate.cx, &dialogTemplate.cy);
dialog = (WIN_DialogData *)SDL_calloc(1, sizeof(*dialog));

View File

@@ -249,25 +249,24 @@ static void WIN_GL_SetupPixelFormat(_THIS, PIXELFORMATDESCRIPTOR *pfd)
}
pfd->iLayerType = PFD_MAIN_PLANE;
pfd->iPixelType = PFD_TYPE_RGBA;
pfd->cRedBits = _this->gl_config.red_size;
pfd->cGreenBits = _this->gl_config.green_size;
pfd->cBlueBits = _this->gl_config.blue_size;
pfd->cAlphaBits = _this->gl_config.alpha_size;
pfd->cRedBits = (BYTE)_this->gl_config.red_size;
pfd->cGreenBits = (BYTE)_this->gl_config.green_size;
pfd->cBlueBits = (BYTE)_this->gl_config.blue_size;
pfd->cAlphaBits = (BYTE)_this->gl_config.alpha_size;
if (_this->gl_config.buffer_size) {
pfd->cColorBits =
_this->gl_config.buffer_size - _this->gl_config.alpha_size;
pfd->cColorBits = (BYTE)(_this->gl_config.buffer_size - _this->gl_config.alpha_size);
} else {
pfd->cColorBits = (pfd->cRedBits + pfd->cGreenBits + pfd->cBlueBits);
}
pfd->cAccumRedBits = _this->gl_config.accum_red_size;
pfd->cAccumGreenBits = _this->gl_config.accum_green_size;
pfd->cAccumBlueBits = _this->gl_config.accum_blue_size;
pfd->cAccumAlphaBits = _this->gl_config.accum_alpha_size;
pfd->cAccumRedBits = (BYTE)_this->gl_config.accum_red_size;
pfd->cAccumGreenBits = (BYTE)_this->gl_config.accum_green_size;
pfd->cAccumBlueBits = (BYTE)_this->gl_config.accum_blue_size;
pfd->cAccumAlphaBits = (BYTE)_this->gl_config.accum_alpha_size;
pfd->cAccumBits =
(pfd->cAccumRedBits + pfd->cAccumGreenBits + pfd->cAccumBlueBits +
pfd->cAccumAlphaBits);
pfd->cDepthBits = _this->gl_config.depth_size;
pfd->cStencilBits = _this->gl_config.stencil_size;
pfd->cDepthBits = (BYTE)_this->gl_config.depth_size;
pfd->cStencilBits = (BYTE)_this->gl_config.stencil_size;
}
/* Choose the closest pixel format that meets or exceeds the target.