Clang-Tidy fixes (#6725)

(cherry picked from commit 3c501b963d)
This commit is contained in:
Pierre Wendling
2022-12-01 16:07:03 -05:00
committed by Sam Lantinga
parent e29c0661cc
commit d0bbfdbfb8
179 changed files with 1260 additions and 1101 deletions

View File

@@ -1340,7 +1340,7 @@ SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access, int w, int
} else if (access == SDL_TEXTUREACCESS_STREAMING) {
/* The pitch is 4 byte aligned */
texture->pitch = (((w * SDL_BYTESPERPIXEL(format)) + 3) & ~3);
texture->pixels = SDL_calloc(1, texture->pitch * h);
texture->pixels = SDL_calloc(1, (size_t)texture->pitch * h);
if (!texture->pixels) {
SDL_DestroyTexture(texture);
return NULL;
@@ -1687,7 +1687,7 @@ static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect,
} else {
/* Use a temporary buffer for updating */
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
const size_t alloclen = rect->h * temp_pitch;
const size_t alloclen = (size_t)rect->h * temp_pitch;
if (alloclen > 0) {
void *temp_pixels = SDL_malloc(alloclen);
if (temp_pixels == NULL) {
@@ -1727,7 +1727,7 @@ static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect,
} else {
/* Use a temporary buffer for updating */
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
const size_t alloclen = rect->h * temp_pitch;
const size_t alloclen = (size_t)rect->h * temp_pitch;
if (alloclen > 0) {
void *temp_pixels = SDL_malloc(alloclen);
if (temp_pixels == NULL) {
@@ -1821,7 +1821,7 @@ static int SDL_UpdateTextureYUVPlanar(SDL_Texture *texture, const SDL_Rect *rect
} else {
/* Use a temporary buffer for updating */
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
const size_t alloclen = rect->h * temp_pitch;
const size_t alloclen = (size_t)rect->h * temp_pitch;
if (alloclen > 0) {
void *temp_pixels = SDL_malloc(alloclen);
if (temp_pixels == NULL) {
@@ -1871,7 +1871,7 @@ static int SDL_UpdateTextureNVPlanar(SDL_Texture *texture, const SDL_Rect *rect,
} else {
/* Use a temporary buffer for updating */
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
const size_t alloclen = rect->h * temp_pitch;
const size_t alloclen = (size_t)rect->h * temp_pitch;
if (alloclen > 0) {
void *temp_pixels = SDL_malloc(alloclen);
if (temp_pixels == NULL) {
@@ -2313,9 +2313,9 @@ static int UpdateLogicalSize(SDL_Renderer *renderer, SDL_bool flush_viewport_cmd
if (renderer->integer_scale) {
if (want_aspect > real_aspect) {
scale = (float)(w / renderer->logical_w);
scale = (float)(w) / renderer->logical_w;
} else {
scale = (float)(h / renderer->logical_h);
scale = (float)(h) / renderer->logical_h;
}
if (scale < 1.0f) {
@@ -2452,10 +2452,12 @@ int SDL_RenderSetViewport(SDL_Renderer *renderer, const SDL_Rect *rect)
if (SDL_GetRendererOutputSize(renderer, &w, &h) < 0) {
return -1;
}
renderer->viewport.x = (double)0;
renderer->viewport.y = (double)0;
renderer->viewport.x = 0.0;
renderer->viewport.y = 0.0;
/* NOLINTBEGIN(clang-analyzer-core.uninitialized.Assign): SDL_GetRendererOutputSize cannot fail */
renderer->viewport.w = (double)w;
renderer->viewport.h = (double)h;
/* NOLINTEND(clang-analyzer-core.uninitialized.Assign) */
}
retval = QueueCmdSetViewport(renderer);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);

View File

@@ -142,7 +142,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
if (rect->x == 0 && rect->y == 0 &&
rect->w == swdata->w && rect->h == swdata->h) {
SDL_memcpy(swdata->pixels, pixels,
(swdata->h * swdata->w) + 2 * ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2));
(size_t)(swdata->h * swdata->w) + 2 * ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2));
} else {
Uint8 *src, *dst;
int row;
@@ -194,7 +194,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
dst =
swdata->planes[0] + rect->y * swdata->pitches[0] +
rect->x * 2;
length = 4 * ((rect->w + 1) / 2);
length = 4 * (((size_t)rect->w + 1) / 2);
for (row = 0; row < rect->h; ++row) {
SDL_memcpy(dst, src, length);
src += pitch;
@@ -206,7 +206,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
{
if (rect->x == 0 && rect->y == 0 && rect->w == swdata->w && rect->h == swdata->h) {
SDL_memcpy(swdata->pixels, pixels,
(swdata->h * swdata->w) + 2 * ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2));
(size_t)(swdata->h * swdata->w) + 2 * ((swdata->h + 1) / 2) * ((swdata->w + 1) / 2));
} else {
Uint8 *src, *dst;
@@ -227,7 +227,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
src = (Uint8 *)pixels + rect->h * pitch;
dst = swdata->pixels + swdata->h * swdata->w;
dst += 2 * ((rect->y + 1) / 2) * ((swdata->w + 1) / 2) + 2 * (rect->x / 2);
length = 2 * ((rect->w + 1) / 2);
length = 2 * (((size_t)rect->w + 1) / 2);
for (row = 0; row < (rect->h + 1) / 2; ++row) {
SDL_memcpy(dst, src, length);
src += 2 * ((pitch + 1) / 2);

View File

@@ -480,9 +480,9 @@ static int D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *textur
}
d3drect.left = x;
d3drect.right = x + w;
d3drect.right = (LONG)x + w;
d3drect.top = y;
d3drect.bottom = y + h;
d3drect.bottom = (LONG)y + h;
result = IDirect3DTexture9_LockRect(texture->staging, 0, &locked, &d3drect, 0);
if (FAILED(result)) {
@@ -493,7 +493,7 @@ static int D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *textur
dst = (Uint8 *)locked.pBits;
length = w * SDL_BYTESPERPIXEL(texture->format);
if (length == pitch && length == locked.Pitch) {
SDL_memcpy(dst, src, length * h);
SDL_memcpy(dst, src, (size_t)length * h);
} else {
if (length > pitch) {
length = pitch;
@@ -676,7 +676,7 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
}
}
*pixels =
(void *)((Uint8 *)texturedata->pixels + rect->y * texturedata->pitch +
(void *)(texturedata->pixels + rect->y * texturedata->pitch +
rect->x * SDL_BYTESPERPIXEL(texture->format));
*pitch = texturedata->pitch;
} else
@@ -691,9 +691,9 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
}
d3drect.left = rect->x;
d3drect.right = rect->x + rect->w;
d3drect.right = (LONG)rect->x + rect->w;
d3drect.top = rect->y;
d3drect.bottom = rect->y + rect->h;
d3drect.bottom = (LONG)rect->y + rect->h;
result = IDirect3DTexture9_LockRect(texturedata->texture.staging, 0, &locked, &d3drect, 0);
if (FAILED(result)) {
@@ -717,7 +717,7 @@ static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
if (texturedata->yuv) {
const SDL_Rect *rect = &texturedata->locked_rect;
void *pixels =
(void *)((Uint8 *)texturedata->pixels + rect->y * texturedata->pitch +
(void *)(texturedata->pixels + rect->y * texturedata->pitch +
rect->x * SDL_BYTESPERPIXEL(texture->format));
D3D_UpdateTexture(renderer, texture, rect, pixels, texturedata->pitch);
} else
@@ -1086,10 +1086,10 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
const SDL_Rect *viewport = &data->drawstate.viewport;
const SDL_Rect *rect = &data->drawstate.cliprect;
RECT d3drect;
d3drect.left = viewport->x + rect->x;
d3drect.top = viewport->y + rect->y;
d3drect.right = viewport->x + rect->x + rect->w;
d3drect.bottom = viewport->y + rect->y + rect->h;
d3drect.left = (LONG)viewport->x + rect->x;
d3drect.top = (LONG)viewport->y + rect->y;
d3drect.right = (LONG)viewport->x + rect->x + rect->w;
d3drect.bottom = (LONG)viewport->y + rect->y + rect->h;
IDirect3DDevice9_SetScissorRect(data->device, &d3drect);
data->drawstate.cliprect_dirty = SDL_FALSE;
}
@@ -1239,7 +1239,8 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
const Vertex *verts = (Vertex *)(((Uint8 *)vertices) + first);
/* DirectX 9 has the same line rasterization semantics as GDI,
so we need to close the endpoint of the line with a second draw call. */
so we need to close the endpoint of the line with a second draw call.
NOLINTNEXTLINE(clang-analyzer-core.NullDereference): FIXME: Can verts truly not be NULL ? */
const SDL_bool close_endpoint = ((count == 2) || (verts[0].x != verts[count - 1].x) || (verts[0].y != verts[count - 1].y));
SetDrawState(data, cmd);
@@ -1326,9 +1327,9 @@ static int D3D_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
}
d3drect.left = rect->x;
d3drect.right = rect->x + rect->w;
d3drect.right = (LONG)rect->x + rect->w;
d3drect.top = rect->y;
d3drect.bottom = rect->y + rect->h;
d3drect.bottom = (LONG)rect->y + rect->h;
result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY);
if (FAILED(result)) {

View File

@@ -702,9 +702,9 @@ static int D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
switch (rotation) {
case DXGI_MODE_ROTATION_IDENTITY:
outRect->left = sdlRect->x;
outRect->right = sdlRect->x + sdlRect->w;
outRect->right = (LONG)sdlRect->x + sdlRect->w;
outRect->top = sdlRect->y;
outRect->bottom = sdlRect->y + sdlRect->h;
outRect->bottom = (LONG)sdlRect->y + sdlRect->h;
if (includeViewportOffset) {
outRect->left += viewport->x;
outRect->right += viewport->x;
@@ -714,7 +714,7 @@ static int D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
break;
case DXGI_MODE_ROTATION_ROTATE270:
outRect->left = sdlRect->y;
outRect->right = sdlRect->y + sdlRect->h;
outRect->right = (LONG)sdlRect->y + sdlRect->h;
outRect->top = viewport->w - sdlRect->x - sdlRect->w;
outRect->bottom = viewport->w - sdlRect->x;
break;
@@ -728,7 +728,7 @@ static int D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
outRect->left = viewport->h - sdlRect->y - sdlRect->h;
outRect->right = viewport->h - sdlRect->y;
outRect->top = sdlRect->x;
outRect->bottom = sdlRect->x + sdlRect->h;
outRect->bottom = (LONG)sdlRect->x + sdlRect->h;
break;
default:
return SDL_SetError("The physical display is in an unknown or unsupported rotation");
@@ -930,7 +930,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
#endif
} else {
result = D3D11_CreateSwapChain(renderer, w, h);
if (FAILED(result)) {
if (FAILED(result) || data->swapChain == NULL) {
goto done;
}
}
@@ -1297,7 +1297,7 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex
dst = textureMemory.pData;
length = w * bpp;
if (length == pitch && length == textureMemory.RowPitch) {
SDL_memcpy(dst, src, length * h);
SDL_memcpy(dst, src, (size_t)length * h);
} else {
if (length > (UINT)pitch) {
length = pitch;
@@ -1448,7 +1448,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
}
textureData->locked_rect = *rect;
*pixels =
(void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch +
(void *)(textureData->pixels + rect->y * textureData->pitch +
rect->x * SDL_BYTESPERPIXEL(texture->format));
*pitch = textureData->pitch;
return 0;
@@ -1519,7 +1519,7 @@ static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
if (textureData->yuv || textureData->nv12) {
const SDL_Rect *rect = &textureData->locked_rect;
void *pixels =
(void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch +
(void *)(textureData->pixels + rect->y * textureData->pitch +
rect->x * SDL_BYTESPERPIXEL(texture->format));
D3D11_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch);
return;

View File

@@ -1104,9 +1104,9 @@ static int D3D12_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
switch (rotation) {
case DXGI_MODE_ROTATION_IDENTITY:
outRect->left = sdlRect->x;
outRect->right = sdlRect->x + sdlRect->w;
outRect->right = (LONG)sdlRect->x + sdlRect->w;
outRect->top = sdlRect->y;
outRect->bottom = sdlRect->y + sdlRect->h;
outRect->bottom = (LONG)sdlRect->y + sdlRect->h;
if (includeViewportOffset) {
outRect->left += viewport->x;
outRect->right += viewport->x;
@@ -1116,7 +1116,7 @@ static int D3D12_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
break;
case DXGI_MODE_ROTATION_ROTATE270:
outRect->left = sdlRect->y;
outRect->right = sdlRect->y + sdlRect->h;
outRect->right = (LONG)sdlRect->y + sdlRect->h;
outRect->top = viewport->w - sdlRect->x - sdlRect->w;
outRect->bottom = viewport->w - sdlRect->x;
break;
@@ -1130,7 +1130,7 @@ static int D3D12_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
outRect->left = viewport->h - sdlRect->y - sdlRect->h;
outRect->right = viewport->h - sdlRect->y;
outRect->top = sdlRect->x;
outRect->bottom = sdlRect->x + sdlRect->h;
outRect->bottom = (LONG)sdlRect->x + sdlRect->h;
break;
default:
return SDL_SetError("The physical display is in an unknown or unsupported rotation");
@@ -1298,7 +1298,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
/* Set the proper rotation for the swap chain. */
if (WIN_IsWindows8OrGreater()) {
if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) {
result = D3D_CALL(data->swapChain, SetRotation, data->rotation);
result = D3D_CALL(data->swapChain, SetRotation, data->rotation); /* NOLINT(clang-analyzer-core.NullDereference) */
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain4::SetRotation"), result);
goto done;
@@ -1316,7 +1316,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
goto done;
}
#else
result = D3D_CALL(data->swapChain, GetBuffer,
result = D3D_CALL(data->swapChain, GetBuffer, /* NOLINT(clang-analyzer-core.NullDereference) */
i,
D3D_GUID(SDL_IID_ID3D12Resource),
(void **)&data->renderTargets[i]);
@@ -1729,7 +1729,7 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res
dst = textureMemory;
length = w * bpp;
if (length == pitch && length == pitchedDesc.RowPitch) {
SDL_memcpy(dst, src, length * h);
SDL_memcpy(dst, src, (size_t)length * h);
} else {
if (length > (UINT)pitch) {
length = pitch;
@@ -1902,7 +1902,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
}
textureData->lockedRect = *rect;
*pixels =
(void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch +
(void *)(textureData->pixels + rect->y * textureData->pitch +
rect->x * SDL_BYTESPERPIXEL(texture->format));
*pitch = textureData->pitch;
return 0;
@@ -2013,7 +2013,7 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
if (textureData->yuv || textureData->nv12) {
const SDL_Rect *rect = &textureData->lockedRect;
void *pixels =
(void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch +
(void *)(textureData->pixels + rect->y * textureData->pitch +
rect->x * SDL_BYTESPERPIXEL(texture->format));
D3D12_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch);
return;

View File

@@ -1286,7 +1286,7 @@ SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const size_t
[data.mtlcmdencoder setFragmentTexture:texturedata.mtltexture atIndex:0];
#if SDL_HAVE_YUV
if (texturedata.yuv || texturedata.nv12) {
[data.mtlcmdencoder setFragmentTexture:texturedata.mtltexture_uv atIndex:1];
[data.mtlcmdencoder setFragmentTexture:texturedata.mtltextureUv atIndex:1];
[data.mtlcmdencoder setFragmentBuffer:data.mtlbufconstants offset:texturedata.conversionBufferOffset atIndex:1];
}
#endif

View File

@@ -50,9 +50,6 @@
http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/opengl_texturedata.html
*/
/* Used to re-create the window with OpenGL capability */
extern int SDL_RecreateWindow(SDL_Window *window, Uint32 flags);
static const float inv255f = 1.0f / 255.0f;
typedef struct GL_FBOList GL_FBOList;
@@ -477,7 +474,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
size_t size;
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
size = texture->h * data->pitch;
size = (size_t)texture->h * data->pitch;
if (texture->format == SDL_PIXELFORMAT_YV12 ||
texture->format == SDL_PIXELFORMAT_IYUV) {
/* Need to add size for the U and V planes */
@@ -695,7 +692,7 @@ static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
GL_TextureData *data = (GL_TextureData *)texture->driverdata;
const int texturebpp = SDL_BYTESPERPIXEL(texture->format);
SDL_assert(texturebpp != 0); /* otherwise, division by zero later. */
SDL_assert_release(texturebpp != 0); /* otherwise, division by zero later. */
GL_ActivateRenderer(renderer);
@@ -1430,12 +1427,12 @@ static int GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
SDL_GetPixelFormatName(temp_format));
}
if (!rect->w || !rect->h) {
if (rect->w == 0 || rect->h == 0) {
return 0; /* nothing to do. */
}
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
temp_pixels = SDL_malloc(rect->h * temp_pitch);
temp_pixels = SDL_malloc((size_t)rect->h * temp_pitch);
if (temp_pixels == NULL) {
return SDL_OutOfMemory();
}

View File

@@ -472,7 +472,7 @@ static SDL_bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_Shader
ctx->glUseProgramObjectARB(data->program);
for (i = 0; i < num_tmus_bound; ++i) {
char tex_name[10];
SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i);
(void)SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i);
location = ctx->glGetUniformLocationARB(data->program, tex_name);
if (location >= 0) {
ctx->glUniform1iARB(location, i);

View File

@@ -46,9 +46,6 @@
#define RENDERER_CONTEXT_MAJOR 2
#define RENDERER_CONTEXT_MINOR 0
/* Used to re-create the window with OpenGL ES capability */
extern int SDL_RecreateWindow(SDL_Window *window, Uint32 flags);
/*************************************************************************************************
* Context structures *
*************************************************************************************************/
@@ -1465,7 +1462,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
size_t size;
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
size = texture->h * data->pitch;
size = (size_t)texture->h * data->pitch;
#if SDL_HAVE_YUV
if (data->yuv) {
/* Need to add size for the U and V planes */
@@ -1565,7 +1562,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff
Uint32 *blob2 = NULL;
#endif
Uint8 *src;
int src_pitch;
size_t src_pitch;
int y;
if ((width == 0) || (height == 0) || (bpp == 0)) {
@@ -1573,7 +1570,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff
}
/* Reformat the texture data into a tightly packed array */
src_pitch = width * bpp;
src_pitch = (size_t)width * bpp;
src = (Uint8 *)pixels;
if (pitch != src_pitch) {
blob = (Uint8 *)SDL_malloc(src_pitch * height);
@@ -1915,7 +1912,7 @@ static int GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
int status;
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
buflen = rect->h * temp_pitch;
buflen = (size_t)rect->h * temp_pitch;
if (buflen == 0) {
return 0; /* nothing to do. */
}

View File

@@ -142,7 +142,7 @@ static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
dst = (Uint8 *)surface->pixels +
rect->y * surface->pitch +
rect->x * surface->format->BytesPerPixel;
length = rect->w * surface->format->BytesPerPixel;
length = (size_t)rect->w * surface->format->BytesPerPixel;
for (row = 0; row < rect->h; ++row) {
SDL_memcpy(dst, src, length);
src += pitch;
@@ -538,9 +538,9 @@ static int SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_
int i;
int count = indices ? num_indices : num_vertices;
void *verts;
int sz = texture ? sizeof(GeometryCopyData) : sizeof(GeometryFillData);
size_t sz = texture != NULL ? sizeof(GeometryCopyData) : sizeof(GeometryFillData);
verts = (void *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
verts = SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
if (verts == NULL) {
return -1;
}
@@ -641,7 +641,7 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
if (drawstate->surface_cliprect_dirty) {
const SDL_Rect *viewport = drawstate->viewport;
const SDL_Rect *cliprect = drawstate->cliprect;
SDL_assert(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
SDL_assert_release(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
if (cliprect != NULL) {
SDL_Rect clip_rect;

View File

@@ -432,7 +432,7 @@ static void transformSurfaceY(SDL_Surface *src, SDL_Surface *dst, int isin, int
/*
* Clear surface to colorkey
*/
SDL_memset(pc, (int)(get_colorkey(src) & 0xff), dst->pitch * dst->h);
SDL_memset(pc, (int)(get_colorkey(src) & 0xff), (size_t)dst->pitch * dst->h);
/*
* Iterate through destination surface
*/

View File

@@ -659,7 +659,7 @@ int SDL_SW_BlitTriangle(
tmp_info.src_pitch = src_pitch;
/* dst */
tmp_info.dst = (Uint8 *)dst_ptr;
tmp_info.dst = dst_ptr;
tmp_info.dst_pitch = dst_pitch;
SDL_BlitTriangle_Slow(&tmp_info, s2_x_area, dstrect, area, bias_w0, bias_w1, bias_w2,
@@ -682,7 +682,7 @@ int SDL_SW_BlitTriangle(
TRIANGLE_BEGIN_LOOP
{
TRIANGLE_GET_TEXTCOORD
Uint8 *sptr = (Uint8 *)((Uint8 *)src_ptr + srcy * src_pitch);
Uint8 *sptr = (Uint8 *)src_ptr + srcy * src_pitch;
dptr[0] = sptr[3 * srcx];
dptr[1] = sptr[3 * srcx + 1];
dptr[2] = sptr[3 * srcx + 2];
@@ -700,7 +700,7 @@ int SDL_SW_BlitTriangle(
TRIANGLE_BEGIN_LOOP
{
TRIANGLE_GET_TEXTCOORD
Uint8 *sptr = (Uint8 *)((Uint8 *)src_ptr + srcy * src_pitch);
Uint8 *sptr = (Uint8 *)src_ptr + srcy * src_pitch;
*dptr = sptr[srcx];
}
TRIANGLE_END_LOOP
@@ -839,14 +839,17 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
break;
case SDL_COPY_ADD:
dstR = srcR + dstR;
if (dstR > 255)
if (dstR > 255) {
dstR = 255;
}
dstG = srcG + dstG;
if (dstG > 255)
if (dstG > 255) {
dstG = 255;
}
dstB = srcB + dstB;
if (dstB > 255)
if (dstB > 255) {
dstB = 255;
}
break;
case SDL_COPY_MOD:
dstR = (srcR * dstR) / 255;
@@ -855,17 +858,21 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
break;
case SDL_COPY_MUL:
dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255;
if (dstR > 255)
if (dstR > 255) {
dstR = 255;
}
dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255;
if (dstG > 255)
if (dstG > 255) {
dstG = 255;
}
dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255;
if (dstB > 255)
if (dstB > 255) {
dstB = 255;
}
dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255;
if (dstA > 255)
if (dstA > 255) {
dstA = 255;
}
break;
}
if (FORMAT_HAS_ALPHA(dstfmt_val)) {