src/render/software/SDL_rotate.c
changeset 12372 bced4041fcc0
parent 12311 b19b09eb9e6d
     1.1 --- a/src/render/software/SDL_rotate.c	Mon Oct 29 19:58:59 2018 -0700
     1.2 +++ b/src/render/software/SDL_rotate.c	Tue Oct 30 07:00:03 2018 -0700
     1.3 @@ -83,7 +83,9 @@
     1.4  _colorkey(SDL_Surface *src)
     1.5  {
     1.6      Uint32 key = 0;
     1.7 -    SDL_GetColorKey(src, &key);
     1.8 +    if (SDL_HasColorKey(src)) {
     1.9 +        SDL_GetColorKey(src, &key);
    1.10 +    }
    1.11      return key;
    1.12  }
    1.13  
    1.14 @@ -150,17 +152,17 @@
    1.15  /* Computes source pointer X/Y increments for a rotation that's a multiple of 90 degrees. */
    1.16  static void
    1.17  computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int flipy,
    1.18 -                          int *sincx, int *sincy, int *signx, int *signy, SDL_Surface *dst)
    1.19 +                          int *sincx, int *sincy, int *signx, int *signy)
    1.20  {
    1.21      int pitch = flipy ? -src->pitch : src->pitch;
    1.22      if (flipx) {
    1.23          bpp = -bpp;
    1.24      }
    1.25      switch (angle) { /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
    1.26 -    case 0: *sincx = bpp; *sincy = pitch - dst->w * *sincx; *signx = *signy = 1; break;
    1.27 -    case 1: *sincx = -pitch; *sincy = bpp - *sincx * dst->h; *signx = 1; *signy = -1; break;
    1.28 -    case 2: *sincx = -bpp; *sincy = -dst->w * *sincx - pitch; *signx = *signy = -1; break;
    1.29 -    case 3: default: *sincx = pitch; *sincy = -*sincx * dst->h - bpp; *signx = -1; *signy = 1; break;
    1.30 +    case 0: *sincx = bpp; *sincy = pitch - src->w * *sincx; *signx = *signy = 1; break;
    1.31 +    case 1: *sincx = -pitch; *sincy = bpp - *sincx * src->h; *signx = 1; *signy = -1; break;
    1.32 +    case 2: *sincx = -bpp; *sincy = -src->w * *sincx - pitch; *signx = *signy = -1; break;
    1.33 +    case 3: default: *sincx = pitch; *sincy = -*sincx * src->h - bpp; *signx = -1; *signy = 1; break;
    1.34      }
    1.35      if (flipx) {
    1.36          *signx = -*signx;
    1.37 @@ -175,9 +177,10 @@
    1.38      int dy, dincy = dst->pitch - dst->w*sizeof(pixelType), sincx, sincy, signx, signy;                      \
    1.39      Uint8 *sp = (Uint8*)src->pixels, *dp = (Uint8*)dst->pixels, *de;                                        \
    1.40                                                                                                              \
    1.41 -    computeSourceIncrements90(src, sizeof(pixelType), angle, flipx, flipy, &sincx, &sincy, &signx, &signy, dst); \
    1.42 -    if (signx < 0) sp += (dst->w-1)*sizeof(pixelType);                                                      \
    1.43 -    if (signy < 0) sp += (dst->h-1)*src->pitch;                                                             \
    1.44 +    computeSourceIncrements90(src, sizeof(pixelType), angle, flipx, flipy, &sincx, &sincy, &signx, &signy); \
    1.45 +    if (signx < 0) sp += (src->w-1)*sizeof(pixelType);                                                      \
    1.46 +    if (signy < 0) sp += (src->h-1)*src->pitch;                                                             \
    1.47 +                                                                                                            \
    1.48      for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) {                                             \
    1.49          if (sincx == sizeof(pixelType)) { /* if advancing src and dest equally, use memcpy */               \
    1.50              SDL_memcpy(dp, sp, dst->w*sizeof(pixelType));                                                   \
    1.51 @@ -423,8 +426,10 @@
    1.52      if (src == NULL)
    1.53          return NULL;
    1.54  
    1.55 -    if (SDL_GetColorKey(src, &colorkey) == 0) {
    1.56 -        colorKeyAvailable = SDL_TRUE;
    1.57 +    if (SDL_HasColorKey(src)) {
    1.58 +        if (SDL_GetColorKey(src, &colorkey) == 0) {
    1.59 +            colorKeyAvailable = SDL_TRUE;
    1.60 +        }
    1.61      }
    1.62  
    1.63      /* This function requires a 32-bit surface or 8-bit surface with a colorkey */