mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-11 06:18:41 +00:00
committed by
Sam Lantinga
parent
e29c0661cc
commit
d0bbfdbfb8
@@ -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;
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user