[mq]: 3027_rleperf.diff
authorSam Lantinga <slouken@libsdl.org>
Fri, 19 Jun 2015 22:12:47 -0700
changeset 97602f5a57f86e24
parent 9759 5bae9db53b80
child 9761 fd7fe355f173
[mq]: 3027_rleperf.diff
src/render/software/SDL_render_sw.c
     1.1 --- a/src/render/software/SDL_render_sw.c	Fri Jun 19 21:17:00 2015 +0200
     1.2 +++ b/src/render/software/SDL_render_sw.c	Fri Jun 19 22:12:47 2015 -0700
     1.3 @@ -253,6 +253,12 @@
     1.4  SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
     1.5  {
     1.6      SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
     1.7 +    /* If the color mod is ever enabled (non-white), permanently disable RLE (which doesn't support
     1.8 +     * color mod) to avoid potentially frequent RLE encoding/decoding.
     1.9 +     */
    1.10 +    if ((texture->r & texture->g & texture->b) != 255) {
    1.11 +        SDL_SetSurfaceRLE(surface, 0);
    1.12 +    }
    1.13      return SDL_SetSurfaceColorMod(surface, texture->r, texture->g,
    1.14                                    texture->b);
    1.15  }
    1.16 @@ -261,6 +267,12 @@
    1.17  SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
    1.18  {
    1.19      SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
    1.20 +    /* If the texture ever has multiple alpha values (surface alpha plus alpha channel), permanently
    1.21 +     * disable RLE (which doesn't support this) to avoid potentially frequent RLE encoding/decoding.
    1.22 +     */
    1.23 +    if (texture->a != 255 && surface->format->Amask) {
    1.24 +        SDL_SetSurfaceRLE(surface, 0);
    1.25 +    }
    1.26      return SDL_SetSurfaceAlphaMod(surface, texture->a);
    1.27  }
    1.28  
    1.29 @@ -268,6 +280,12 @@
    1.30  SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
    1.31  {
    1.32      SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
    1.33 +    /* If add or mod blending are ever enabled, permanently disable RLE (which doesn't support
    1.34 +     * them) to avoid potentially frequent RLE encoding/decoding.
    1.35 +     */
    1.36 +    if ((texture->blendMode == SDL_BLENDMODE_ADD || texture->blendMode == SDL_BLENDMODE_MOD)) {
    1.37 +        SDL_SetSurfaceRLE(surface, 0);
    1.38 +    }
    1.39      return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
    1.40  }
    1.41  
    1.42 @@ -553,6 +571,10 @@
    1.43      if ( srcrect->w == final_rect.w && srcrect->h == final_rect.h ) {
    1.44          return SDL_BlitSurface(src, srcrect, surface, &final_rect);
    1.45      } else {
    1.46 +        /* If scaling is ever done, permanently disable RLE (which doesn't support scaling)
    1.47 +         * to avoid potentially frequent RLE encoding/decoding.
    1.48 +         */
    1.49 +        SDL_SetSurfaceRLE(surface, 0);
    1.50          return SDL_BlitScaled(src, srcrect, surface, &final_rect);
    1.51      }
    1.52  }