From ce9226164199aa90ace06c2ca3f5e986902cb629 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Thu, 15 Aug 2019 21:55:40 -0700 Subject: [PATCH] Some more cleanup to make SDL common code friendly to SDL1 and SDL2 --- sc2/src/libs/graphics/sdl/palette.h | 4 ++++ sc2/src/libs/graphics/sdl/primitives.c | 8 +++++++- sc2/src/libs/graphics/sdl/sdl_common.h | 1 - 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sc2/src/libs/graphics/sdl/palette.h b/sc2/src/libs/graphics/sdl/palette.h index 182a14671..2cefe7c0a 100644 --- a/sc2/src/libs/graphics/sdl/palette.h +++ b/sc2/src/libs/graphics/sdl/palette.h @@ -46,7 +46,11 @@ ColorToNative (Color color) native.r = color.r; native.g = color.g; native.b = color.b; +#if SDL_MAJOR_VERSION == 1 native.unused = 0; +#else + native.a = color.a; +#endif return native; } diff --git a/sc2/src/libs/graphics/sdl/primitives.c b/sc2/src/libs/graphics/sdl/primitives.c index 3cf16b49a..c83521334 100644 --- a/sc2/src/libs/graphics/sdl/primitives.c +++ b/sc2/src/libs/graphics/sdl/primitives.c @@ -533,12 +533,18 @@ blt_prim(SDL_Surface *src, SDL_Rect src_r, RenderPixelFn plot, int factor, mask = srcfmt->Amask; key = 0; } +#if SDL_MAJOR_VERSION == 1 else if (src->flags & SDL_SRCCOLORKEY) { // colorkey transparency mask = ~srcfmt->Amask; key = srcfmt->colorkey & mask; } - +#else + else if (SDL_GetColorKey (src, &key) == 0) + { + mask = ~0; + } +#endif // TODO: calculate the source and destination pointers directly // instead of using the plot(x,y) version for (y = 0; y < src_r.h; ++y) diff --git a/sc2/src/libs/graphics/sdl/sdl_common.h b/sc2/src/libs/graphics/sdl/sdl_common.h index dea339612..489f946b7 100644 --- a/sc2/src/libs/graphics/sdl/sdl_common.h +++ b/sc2/src/libs/graphics/sdl/sdl_common.h @@ -21,7 +21,6 @@ #include "port.h" #include SDL_INCLUDE(SDL.h) -#include SDL_INCLUDE(SDL_byteorder.h) #include "../gfxintrn.h" #include "libs/graphics/tfb_draw.h"