Fixed bug 1822 - Inconsistent renderer behaviour on rotation
authorSam Lantinga <slouken@libsdl.org>
Fri, 11 Nov 2016 13:38:39 -0800
changeset 10606c7209688838b
parent 10605 8a059b7b01c4
child 10607 264f6495d712
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
     1.1 --- a/src/render/software/SDL_rotate.c	Fri Nov 11 13:29:23 2016 -0800
     1.2 +++ b/src/render/software/SDL_rotate.c	Fri Nov 11 13:38:39 2016 -0800
     1.3 @@ -417,7 +417,7 @@
     1.4      SDL_Surface *rz_dst;
     1.5      int is32bit, angle90;
     1.6      int i;
     1.7 -    Uint8 r = 0, g = 0, b = 0;
     1.8 +    Uint8 r = 0, g = 0, b = 0, a = 0;
     1.9      Uint32 colorkey = 0;
    1.10      int colorKeyAvailable = 0;
    1.11      double sangleinv, cangleinv;
    1.12 @@ -428,12 +428,12 @@
    1.13      if (src == NULL)
    1.14          return (NULL);
    1.15  
    1.16 -    if (src->flags & SDL_TRUE/* SDL_SRCCOLORKEY */)
    1.17 -    {
    1.18 +    if (src->flags & SDL_TRUE/* SDL_SRCCOLORKEY */) {
    1.19          colorkey = _colorkey(src);
    1.20 -        SDL_GetRGB(colorkey, src->format, &r, &g, &b);
    1.21 +        SDL_GetRGBA(colorkey, src->format, &r, &g, &b, &a);
    1.22          colorKeyAvailable = 1;
    1.23      }
    1.24 +
    1.25      /*
    1.26      * Determine if source surface is 32bit or 8bit
    1.27      */
    1.28 @@ -485,10 +485,10 @@
    1.29      /* Adjust for guard rows */
    1.30      rz_dst->h = dstheight;
    1.31  
    1.32 -    if (colorKeyAvailable == 1){
    1.33 -        colorkey = SDL_MapRGB(rz_dst->format, r, g, b);
    1.34 +    if (colorKeyAvailable == 1) {
    1.35 +        colorkey = SDL_MapRGBA(rz_dst->format, r, g, b, a);
    1.36  
    1.37 -        SDL_FillRect(rz_dst, NULL, colorkey );
    1.38 +        SDL_FillRect(rz_dst, NULL, colorkey);
    1.39      }
    1.40  
    1.41      /*
    1.42 @@ -523,10 +523,9 @@
    1.43              _transformSurfaceRGBA(rz_src, rz_dst, centerx, centery, (int) (sangleinv), (int) (cangleinv), flipx, flipy, smooth);
    1.44          }
    1.45          /*
    1.46 -        * Turn on source-alpha support
    1.47 -        */
    1.48 +         * Turn on source-alpha support
    1.49 +         */
    1.50          /* SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255); */
    1.51 -        SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
    1.52      } else {
    1.53          /*
    1.54          * Copy palette and colorkey info
    1.55 @@ -543,7 +542,12 @@
    1.56          } else {
    1.57              transformSurfaceY(rz_src, rz_dst, centerx, centery, (int)(sangleinv), (int)(cangleinv), flipx, flipy);
    1.58          }
    1.59 -        SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
    1.60 +    }
    1.61 +
    1.62 +    if (colorKeyAvailable == 1) {
    1.63 +       SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, colorkey);
    1.64 +    } else {
    1.65 +       SDL_SetColorKey(rz_dst, SDL_FALSE, 0);
    1.66      }
    1.67  
    1.68      /* copy alpha mod, color mod, and blend mode */