A few #defines to reduce SDL2 footprint.

Only applied when library is statically linked
This commit is contained in:
Sylvain Becker
2020-01-21 21:33:40 +01:00
parent 25c88ea903
commit 7df22cf2c2
7 changed files with 75 additions and 13 deletions

View File

@@ -445,7 +445,7 @@ RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst,
/* blit a colorkeyed RLE surface */
int SDLCALL
static int SDLCALL
SDL_RLEBlit(SDL_Surface * surf_src, SDL_Rect * srcrect,
SDL_Surface * surf_dst, SDL_Rect * dstrect)
{
@@ -723,7 +723,7 @@ RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst,
}
/* blit a pixel-alpha RLE surface */
int SDLCALL
static int SDLCALL
SDL_RLEAlphaBlit(SDL_Surface * surf_src, SDL_Rect * srcrect,
SDL_Surface * surf_dst, SDL_Rect * dstrect)
{

View File

@@ -27,10 +27,6 @@
/* Useful functions and variables from SDL_RLEaccel.c */
extern int SDL_RLESurface(SDL_Surface * surface);
extern int SDLCALL SDL_RLEBlit (SDL_Surface * src, SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect);
extern int SDLCALL SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect);
extern void SDL_UnRLESurface(SDL_Surface * surface, int recode);
#endif /* SDL_RLEaccel_c_h_ */

View File

@@ -202,22 +202,27 @@ SDL_CalculateBlit(SDL_Surface * surface)
return SDL_SetError("Blit combination not supported");
}
#if SDL_HAVE_RLE
/* Clean everything out to start */
if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
SDL_UnRLESurface(surface, 1);
}
#endif
map->blit = SDL_SoftBlit;
map->info.src_fmt = surface->format;
map->info.src_pitch = surface->pitch;
map->info.dst_fmt = dst->format;
map->info.dst_pitch = dst->pitch;
#if SDL_HAVE_RLE
/* See if we can do RLE acceleration */
if (map->info.flags & SDL_COPY_RLE_DESIRED) {
if (SDL_RLESurface(surface) == 0) {
return 0;
}
}
#endif
/* Choose a standard blit function */
if (map->identity && !(map->info.flags & ~SDL_COPY_RLE_DESIRED)) {
@@ -226,17 +231,30 @@ SDL_CalculateBlit(SDL_Surface * surface)
/* Greater than 8 bits per channel not supported yet */
SDL_InvalidateMap(map);
return SDL_SetError("Blit combination not supported");
} else if (surface->format->BitsPerPixel < 8 &&
}
#if SDL_HAVE_BLIT_0
else if (surface->format->BitsPerPixel < 8 &&
SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
blit = SDL_CalculateBlit0(surface);
} else if (surface->format->BytesPerPixel == 1 &&
}
#endif
#if SDL_HAVE_BLIT_1
else if (surface->format->BytesPerPixel == 1 &&
SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
blit = SDL_CalculateBlit1(surface);
} else if (map->info.flags & SDL_COPY_BLEND) {
}
#endif
#if SDL_HAVE_BLIT_A
else if (map->info.flags & SDL_COPY_BLEND) {
blit = SDL_CalculateBlitA(surface);
} else {
}
#endif
#if SDL_HAVE_BLIT_N
else {
blit = SDL_CalculateBlitN(surface);
}
#endif
#if SDL_HAVE_BLIT_AUTO
if (blit == NULL) {
Uint32 src_format = surface->format->format;
Uint32 dst_format = dst->format->format;
@@ -245,6 +263,8 @@ SDL_CalculateBlit(SDL_Surface * surface)
SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags,
SDL_GeneratedBlitFuncTable);
}
#endif
#ifndef TEST_SLOW_BLIT
if (blit == NULL)
#endif

View File

@@ -1003,9 +1003,11 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst)
/* Clear out any previous mapping */
map = src->map;
#if SDL_HAVE_RLE
if ((src->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
SDL_UnRLESurface(src, 1);
}
#endif
SDL_InvalidateMap(map);
/* Figure out what kind of mapping we're doing */

View File

@@ -905,11 +905,13 @@ int
SDL_LockSurface(SDL_Surface * surface)
{
if (!surface->locked) {
#if SDL_HAVE_RLE
/* Perform the lock */
if (surface->flags & SDL_RLEACCEL) {
SDL_UnRLESurface(surface, 1);
surface->flags |= SDL_RLEACCEL; /* save accel'd state */
}
#endif
}
/* Increment the surface lock count, for recursive locks */
@@ -930,11 +932,13 @@ SDL_UnlockSurface(SDL_Surface * surface)
return;
}
#if SDL_HAVE_RLE
/* Update RLE encoded surface with new data */
if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
surface->flags &= ~SDL_RLEACCEL; /* stop lying */
SDL_RLESurface(surface);
}
#endif
}
/*
@@ -1210,6 +1214,7 @@ int SDL_ConvertPixels(int width, int height,
return SDL_InvalidParamError("dst_pitch");
}
#if SDL_HAVE_YUV
if (SDL_ISPIXELFORMAT_FOURCC(src_format) && SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
return SDL_ConvertPixels_YUV_to_YUV(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch);
} else if (SDL_ISPIXELFORMAT_FOURCC(src_format)) {
@@ -1217,6 +1222,12 @@ int SDL_ConvertPixels(int width, int height,
} else if (SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
return SDL_ConvertPixels_RGB_to_YUV(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch);
}
#else
if (SDL_ISPIXELFORMAT_FOURCC(src_format) || SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
SDL_SetError("SDL not built with YUV support");
return -1;
}
#endif
/* Fast path for same format copy */
if (src_format == dst_format) {
@@ -1269,9 +1280,11 @@ SDL_FreeSurface(SDL_Surface * surface)
while (surface->locked > 0) {
SDL_UnlockSurface(surface);
}
#if SDL_HAVE_RLE
if (surface->flags & SDL_RLEACCEL) {
SDL_UnRLESurface(surface, 0);
}
#endif
if (surface->format) {
SDL_SetSurfacePalette(surface, NULL);
SDL_FreeFormat(surface->format);