diff --git a/SourceS/sdl2_to_1_2_backports.h b/SourceS/sdl2_to_1_2_backports.h index c35e13e8d..fe9ed24d9 100644 --- a/SourceS/sdl2_to_1_2_backports.h +++ b/SourceS/sdl2_to_1_2_backports.h @@ -217,17 +217,7 @@ SDL_FreePalette(SDL_Palette *palette) inline bool SDL_HasColorKey(SDL_Surface *surface) { - return (surface->flags & (SDL_SRCCOLORKEY | SDL_RLEACCELOK)) != 0; -} - -inline int SDL_GetColorKey(SDL_Surface *surface, Uint32 *colorkey) -{ - if (!SDL_HasColorKey(surface)) { - SDL_SetError("Surface doesn't have a colorkey"); - return -1; - } - *colorkey = surface->format->colorkey; - return 0; + return (surface->flags & SDL_SRCCOLORKEY) != 0; } //= Pixel formats diff --git a/SourceS/sdl_compat.h b/SourceS/sdl_compat.h index aac01ef42..9c14ad16c 100644 --- a/SourceS/sdl_compat.h +++ b/SourceS/sdl_compat.h @@ -14,7 +14,6 @@ #define SDLC_KEYSTATE_LEFT SDL_SCANCODE_LEFT #define SDLC_KEYSTATE_RIGHT SDL_SCANCODE_RIGHT #else -#include "sdl2_to_1_2_backports.h" #define SDLC_KEYSTATE_LEFTCTRL SDLK_LCTRL #define SDLC_KEYSTATE_RIGHTCTRL SDLK_RCTRL #define SDLC_KEYSTATE_LEFTSHIFT SDLK_LSHIFT @@ -27,14 +26,6 @@ #define SDLC_KEYSTATE_RIGHT SDLK_RIGHT #endif -inline bool SDLC_PixelFormatEq(const SDL_PixelFormat *a, const SDL_PixelFormat *b) { -#ifndef USE_SDL1 - return a->format == b->format; -#else - return SDLBackport_PixelFormatFormatEq(a, b); -#endif -} - inline const Uint8 *SDLC_GetKeyState() { #ifndef USE_SDL1 diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index 06da4adc3..29d996009 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -179,16 +179,20 @@ void BltFast(SDL_Rect *src_rect, SDL_Rect *dst_rect) void Blit(SDL_Surface *src, SDL_Rect *src_rect, SDL_Rect *dst_rect) { SDL_Surface *dst = GetOutputSurface(); +#ifndef USE_SDL1 + if (SDL_BlitSurface(src, src_rect, dst, dst_rect) < 0) + ErrSdl(); + return; +#else if (!OutputRequiresScaling()) { if (SDL_BlitSurface(src, src_rect, dst, dst_rect) < 0) ErrSdl(); return; } - - ScaleOutputRect(dst_rect); + if (dst_rect != nullptr) ScaleOutputRect(dst_rect); // Same pixel format: We can call BlitScaled directly. - if (SDLC_PixelFormatEq(src->format, dst->format)) { + if (SDLBackport_PixelFormatFormatEq(src->format, dst->format)) { if (SDL_BlitScaled(src, src_rect, dst, dst_rect) < 0) ErrSdl(); return; @@ -198,16 +202,9 @@ void Blit(SDL_Surface *src, SDL_Rect *src_rect, SDL_Rect *dst_rect) if (SDL_HasColorKey(src)) { SDL_Surface *stretched = SDL_CreateRGBSurface(SDL_SWSURFACE, dst_rect->w, dst_rect->h, src->format->BitsPerPixel, src->format->Rmask, src->format->Gmask, src->format->BitsPerPixel, src->format->Amask); - Uint32 colorkey; - SDL_GetColorKey(src, &colorkey); - SDLC_SetColorKey(stretched, colorkey); -#ifndef USE_SDL1 - if (SDL_ISPIXELFORMAT_INDEXED(src->format->format)) - SDL_SetSurfacePalette(stretched, src->format->palette); -#else + SDL_SetColorKey(stretched, SDL_SRCCOLORKEY, src->format->colorkey); if (src->format->palette != nullptr) SDL_SetPalette(stretched, SDL_LOGPAL, src->format->palette->colors, 0, src->format->palette->ncolors); -#endif SDL_Rect stretched_rect = { 0, 0, dst_rect->w, dst_rect->h }; if (SDL_SoftStretch(src, src_rect, stretched, &stretched_rect) < 0 || SDL_BlitSurface(stretched, &stretched_rect, dst, dst_rect) < 0) { @@ -226,6 +223,7 @@ void Blit(SDL_Surface *src, SDL_Rect *src_rect, SDL_Rect *dst_rect) ErrSdl(); } SDL_FreeSurface(converted); +#endif } /**