From: Ingo Ruhnke Date: Wed, 30 Jul 2014 17:57:56 +0000 (+0200) Subject: Removed OLD_SDL1 software rendering code from SDL_Renderer X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=33d0eb9e306a887fef1bfc0026a3020a13d8f389;p=supertux.git Removed OLD_SDL1 software rendering code from SDL_Renderer --- diff --git a/src/video/sdl/sdl_renderer.cpp b/src/video/sdl/sdl_renderer.cpp index 91ef5ce8c..f75137c8e 100644 --- a/src/video/sdl/sdl_renderer.cpp +++ b/src/video/sdl/sdl_renderer.cpp @@ -29,90 +29,6 @@ #include #include "SDL2/SDL_video.h" -namespace { - -SDL_Surface *apply_alpha(SDL_Surface *src, float alpha_factor) -{ - // FIXME: This is really slow - assert(src->format->Amask); - int alpha = (int) (alpha_factor * 256); - SDL_Surface *dst = SDL_CreateRGBSurface(src->flags, src->w, src->h, src->format->BitsPerPixel, src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask); - int bpp = dst->format->BytesPerPixel; - if(SDL_MUSTLOCK(src)) - { - SDL_LockSurface(src); - } - if(SDL_MUSTLOCK(dst)) - { - SDL_LockSurface(dst); - } - for(int y = 0;y < dst->h;y++) { - for(int x = 0;x < dst->w;x++) { - Uint8 *srcpixel = (Uint8 *) src->pixels + y * src->pitch + x * bpp; - Uint8 *dstpixel = (Uint8 *) dst->pixels + y * dst->pitch + x * bpp; - Uint32 mapped = 0; - switch(bpp) { - case 1: - mapped = *srcpixel; - break; - case 2: - mapped = *(Uint16 *)srcpixel; - break; - case 3: -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - mapped |= srcpixel[0] << 16; - mapped |= srcpixel[1] << 8; - mapped |= srcpixel[2] << 0; -#else - mapped |= srcpixel[0] << 0; - mapped |= srcpixel[1] << 8; - mapped |= srcpixel[2] << 16; -#endif - break; - case 4: - mapped = *(Uint32 *)srcpixel; - break; - } - Uint8 r, g, b, a; - SDL_GetRGBA(mapped, src->format, &r, &g, &b, &a); - mapped = SDL_MapRGBA(dst->format, r, g, b, (a * alpha) >> 8); - switch(bpp) { - case 1: - *dstpixel = mapped; - break; - case 2: - *(Uint16 *)dstpixel = mapped; - break; - case 3: -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - dstpixel[0] = (mapped >> 16) & 0xff; - dstpixel[1] = (mapped >> 8) & 0xff; - dstpixel[2] = (mapped >> 0) & 0xff; -#else - dstpixel[0] = (mapped >> 0) & 0xff; - dstpixel[1] = (mapped >> 8) & 0xff; - dstpixel[2] = (mapped >> 16) & 0xff; -#endif - break; - case 4: - *(Uint32 *)dstpixel = mapped; - break; - } - } - } - if(SDL_MUSTLOCK(dst)) - { - SDL_UnlockSurface(dst); - } - if(SDL_MUSTLOCK(src)) - { - SDL_UnlockSurface(src); - } - return dst; -} - -} // namespace - SDLRenderer::SDLRenderer() : window(), renderer()