mirror of https://github.com/encounter/SDL.git
Fixed bug 4188 - Software renderer SDL_RenderCopyEx blits corrupt image under certain cases
duckgrease SDL_RenderCopyEx blits wrong image (in some cases it's bunch of alternating horizontal lines, some cases it's image from the wrong coordinate, and in some cases it's just a bunch of garbled pixels), when the following conditions are met: - Use software renderer. - Enable either horizontal or vertical flip. - source and destination rectangles must have same width and height, and must be smaller than the size of the texture. - source rectangle's X and Y coordinates must be 0.
This commit is contained in:
parent
88b3252555
commit
82c2f04e61
|
@ -150,17 +150,17 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle,
|
|||
/* Computes source pointer X/Y increments for a rotation that's a multiple of 90 degrees. */
|
||||
static void
|
||||
computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int flipy,
|
||||
int *sincx, int *sincy, int *signx, int *signy)
|
||||
int *sincx, int *sincy, int *signx, int *signy, SDL_Surface *dst)
|
||||
{
|
||||
int pitch = flipy ? -src->pitch : src->pitch;
|
||||
if (flipx) {
|
||||
bpp = -bpp;
|
||||
}
|
||||
switch (angle) { /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
case 0: *sincx = bpp; *sincy = pitch - src->w * *sincx; *signx = *signy = 1; break;
|
||||
case 1: *sincx = -pitch; *sincy = bpp - *sincx * src->h; *signx = 1; *signy = -1; break;
|
||||
case 2: *sincx = -bpp; *sincy = -src->w * *sincx - pitch; *signx = *signy = -1; break;
|
||||
case 3: default: *sincx = pitch; *sincy = -*sincx * src->h - bpp; *signx = -1; *signy = 1; break;
|
||||
case 0: *sincx = bpp; *sincy = pitch - dst->w * *sincx; *signx = *signy = 1; break;
|
||||
case 1: *sincx = -pitch; *sincy = bpp - *sincx * dst->h; *signx = 1; *signy = -1; break;
|
||||
case 2: *sincx = -bpp; *sincy = -dst->w * *sincx - pitch; *signx = *signy = -1; break;
|
||||
case 3: default: *sincx = pitch; *sincy = -*sincx * dst->h - bpp; *signx = -1; *signy = 1; break;
|
||||
}
|
||||
if (flipx) {
|
||||
*signx = -*signx;
|
||||
|
@ -175,10 +175,9 @@ computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int
|
|||
int dy, dincy = dst->pitch - dst->w*sizeof(pixelType), sincx, sincy, signx, signy; \
|
||||
Uint8 *sp = (Uint8*)src->pixels, *dp = (Uint8*)dst->pixels, *de; \
|
||||
\
|
||||
computeSourceIncrements90(src, sizeof(pixelType), angle, flipx, flipy, &sincx, &sincy, &signx, &signy); \
|
||||
if (signx < 0) sp += (src->w-1)*sizeof(pixelType); \
|
||||
if (signy < 0) sp += (src->h-1)*src->pitch; \
|
||||
\
|
||||
computeSourceIncrements90(src, sizeof(pixelType), angle, flipx, flipy, &sincx, &sincy, &signx, &signy, dst); \
|
||||
if (signx < 0) sp += (dst->w-1)*sizeof(pixelType); \
|
||||
if (signy < 0) sp += (dst->h-1)*src->pitch; \
|
||||
for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) { \
|
||||
if (sincx == sizeof(pixelType)) { /* if advancing src and dest equally, use memcpy */ \
|
||||
SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \
|
||||
|
|
Loading…
Reference in New Issue