From 77000ff8cb573b8162874e1f9dbeb25af5f534b2 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 11 Nov 2016 13:38:39 -0800 Subject: [PATCH] Fixed bug 1822 - Inconsistent renderer behaviour on rotation Sylvain 2016-11-07 08:49:34 UTC when rotated +90 or -90, some transparent lines appears, though there is no Alpha or ColorKey. if you set a dummy colorkey, it will remove the line ... if you set a some alpha mod, the +90/-90 get transparent but not the 0/180 ... --- src/render/software/SDL_rotate.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index 0141d174d9fe5..29168a9862b5f 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -417,7 +417,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, SDL_Surface *rz_dst; int is32bit, angle90; int i; - Uint8 r = 0, g = 0, b = 0; + Uint8 r = 0, g = 0, b = 0, a = 0; Uint32 colorkey = 0; int colorKeyAvailable = 0; double sangleinv, cangleinv; @@ -428,12 +428,12 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, if (src == NULL) return (NULL); - if (src->flags & SDL_TRUE/* SDL_SRCCOLORKEY */) - { + if (src->flags & SDL_TRUE/* SDL_SRCCOLORKEY */) { colorkey = _colorkey(src); - SDL_GetRGB(colorkey, src->format, &r, &g, &b); + SDL_GetRGBA(colorkey, src->format, &r, &g, &b, &a); colorKeyAvailable = 1; } + /* * Determine if source surface is 32bit or 8bit */ @@ -485,10 +485,10 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, /* Adjust for guard rows */ rz_dst->h = dstheight; - if (colorKeyAvailable == 1){ - colorkey = SDL_MapRGB(rz_dst->format, r, g, b); + if (colorKeyAvailable == 1) { + colorkey = SDL_MapRGBA(rz_dst->format, r, g, b, a); - SDL_FillRect(rz_dst, NULL, colorkey ); + SDL_FillRect(rz_dst, NULL, colorkey); } /* @@ -523,10 +523,9 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, _transformSurfaceRGBA(rz_src, rz_dst, centerx, centery, (int) (sangleinv), (int) (cangleinv), flipx, flipy, smooth); } /* - * Turn on source-alpha support - */ + * Turn on source-alpha support + */ /* SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255); */ - SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); } else { /* * Copy palette and colorkey info @@ -543,7 +542,12 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, } else { transformSurfaceY(rz_src, rz_dst, centerx, centery, (int)(sangleinv), (int)(cangleinv), flipx, flipy); } - SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); + } + + if (colorKeyAvailable == 1) { + SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, colorkey); + } else { + SDL_SetColorKey(rz_dst, SDL_FALSE, 0); } /* copy alpha mod, color mod, and blend mode */