mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-13 05:16:01 +00:00
Remove depth field from SDL_CreateRGBSurfaceWithFormat and SDL_Create… (#6685)
* Remove depth field from SDL_CreateRGBSurfaceWithFormat and SDL_CreateRGBSurfaceWithFormatFrom * Removed unused 'flags' parameter from SDL_CreateRGBSurface and SDL_CreateRGBSurfaceWithFormat * Removed unused 'flags' parameter from SDL_ConvertSurface and SDL_ConvertSurfaceFormat
This commit is contained in:
@@ -68,21 +68,16 @@ SDL_CalculatePitch(Uint32 format, size_t width, SDL_bool minimal)
|
||||
return pitch;
|
||||
}
|
||||
|
||||
/* TODO: In SDL 3, drop the unused flags and depth parameters */
|
||||
/*
|
||||
* Create an empty RGB surface of the appropriate depth using the given
|
||||
* enum SDL_PIXELFORMAT_* format
|
||||
*/
|
||||
SDL_Surface *
|
||||
SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
|
||||
Uint32 format)
|
||||
SDL_CreateRGBSurfaceWithFormat(int width, int height, Uint32 format)
|
||||
{
|
||||
size_t pitch;
|
||||
SDL_Surface *surface;
|
||||
|
||||
/* The flags are no longer used, make the compiler happy */
|
||||
(void)flags;
|
||||
|
||||
if (width < 0) {
|
||||
SDL_InvalidParamError("width");
|
||||
return NULL;
|
||||
@@ -176,13 +171,11 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
|
||||
return surface;
|
||||
}
|
||||
|
||||
/* TODO: In SDL 3, drop the unused flags parameter */
|
||||
/*
|
||||
* Create an empty RGB surface of the appropriate depth
|
||||
*/
|
||||
SDL_Surface *
|
||||
SDL_CreateRGBSurface(Uint32 flags,
|
||||
int width, int height, int depth,
|
||||
SDL_CreateRGBSurface(int width, int height, int depth,
|
||||
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
||||
{
|
||||
Uint32 format;
|
||||
@@ -194,7 +187,7 @@ SDL_CreateRGBSurface(Uint32 flags,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return SDL_CreateRGBSurfaceWithFormat(flags, width, height, depth, format);
|
||||
return SDL_CreateRGBSurfaceWithFormat(width, height, format);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -234,7 +227,7 @@ SDL_CreateRGBSurfaceFrom(void *pixels,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format);
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, 0, format);
|
||||
if (surface != NULL) {
|
||||
surface->flags |= SDL_PREALLOC;
|
||||
surface->pixels = pixels;
|
||||
@@ -246,14 +239,13 @@ SDL_CreateRGBSurfaceFrom(void *pixels,
|
||||
return surface;
|
||||
}
|
||||
|
||||
/* TODO: In SDL 3, drop the unused depth parameter */
|
||||
/*
|
||||
* Create an RGB surface from an existing memory buffer using the given given
|
||||
* enum SDL_PIXELFORMAT_* format
|
||||
*/
|
||||
SDL_Surface *
|
||||
SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
|
||||
int width, int height, int depth, int pitch,
|
||||
int width, int height, int pitch,
|
||||
Uint32 format)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
@@ -276,7 +268,7 @@ SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format);
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, 0, format);
|
||||
if (surface != NULL) {
|
||||
surface->flags |= SDL_PREALLOC;
|
||||
surface->pixels = pixels;
|
||||
@@ -1034,13 +1026,11 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
|
||||
SDL_Rect srcrect2;
|
||||
int is_complex_copy_flags = (src->map->info.flags & complex_copy_flags);
|
||||
|
||||
Uint32 flags;
|
||||
Uint8 r, g, b;
|
||||
Uint8 alpha;
|
||||
SDL_BlendMode blendMode;
|
||||
|
||||
/* Save source infos */
|
||||
flags = src->flags;
|
||||
SDL_GetSurfaceColorMod(src, &r, &g, &b);
|
||||
SDL_GetSurfaceAlphaMod(src, &alpha);
|
||||
SDL_GetSurfaceBlendMode(src, &blendMode);
|
||||
@@ -1062,7 +1052,7 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
|
||||
} else {
|
||||
fmt = SDL_PIXELFORMAT_ARGB8888;
|
||||
}
|
||||
tmp1 = SDL_CreateRGBSurfaceWithFormat(flags, src->w, src->h, 0, fmt);
|
||||
tmp1 = SDL_CreateRGBSurfaceWithFormat(src->w, src->h, fmt);
|
||||
SDL_LowerBlit(src, srcrect, tmp1, &tmprect);
|
||||
|
||||
|
||||
@@ -1078,7 +1068,7 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
|
||||
/* Intermediate scaling */
|
||||
if (is_complex_copy_flags || src->format->format != dst->format->format) {
|
||||
SDL_Rect tmprect;
|
||||
SDL_Surface *tmp2 = SDL_CreateRGBSurfaceWithFormat(flags, dstrect->w, dstrect->h, 0, src->format->format);
|
||||
SDL_Surface *tmp2 = SDL_CreateRGBSurfaceWithFormat(dstrect->w, dstrect->h, src->format->format);
|
||||
SDL_SoftStretchLinear(src, &srcrect2, tmp2, NULL);
|
||||
|
||||
SDL_SetSurfaceColorMod(tmp2, r, g, b);
|
||||
@@ -1150,15 +1140,14 @@ SDL_UnlockSurface(SDL_Surface * surface)
|
||||
SDL_Surface *
|
||||
SDL_DuplicateSurface(SDL_Surface * surface)
|
||||
{
|
||||
return SDL_ConvertSurface(surface, surface->format, surface->flags);
|
||||
return SDL_ConvertSurface(surface, surface->format);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a surface into the specified pixel format.
|
||||
*/
|
||||
SDL_Surface *
|
||||
SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
Uint32 flags)
|
||||
SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format)
|
||||
{
|
||||
SDL_Surface *convert;
|
||||
Uint32 copy_flags;
|
||||
@@ -1195,7 +1184,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
}
|
||||
|
||||
/* Create a new surface with the desired format */
|
||||
convert = SDL_CreateRGBSurface(flags, surface->w, surface->h,
|
||||
convert = SDL_CreateRGBSurface(surface->w, surface->h,
|
||||
format->BitsPerPixel, format->Rmask,
|
||||
format->Gmask, format->Bmask,
|
||||
format->Amask);
|
||||
@@ -1340,7 +1329,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
int converted_colorkey = 0;
|
||||
|
||||
/* Create a dummy surface to get the colorkey converted */
|
||||
tmp = SDL_CreateRGBSurface(0, 1, 1,
|
||||
tmp = SDL_CreateRGBSurface(1, 1,
|
||||
surface->format->BitsPerPixel, surface->format->Rmask,
|
||||
surface->format->Gmask, surface->format->Bmask,
|
||||
surface->format->Amask);
|
||||
@@ -1355,7 +1344,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
tmp->map->info.flags &= ~SDL_COPY_COLORKEY;
|
||||
|
||||
/* Convertion of the colorkey */
|
||||
tmp2 = SDL_ConvertSurface(tmp, format, 0);
|
||||
tmp2 = SDL_ConvertSurface(tmp, format);
|
||||
|
||||
/* Get the converted colorkey */
|
||||
SDL_memcpy(&converted_colorkey, tmp2->pixels, tmp2->format->BytesPerPixel);
|
||||
@@ -1381,7 +1370,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
(copy_flags & SDL_COPY_MODULATE_ALPHA)) {
|
||||
SDL_SetSurfaceBlendMode(convert, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) {
|
||||
if ((copy_flags & SDL_COPY_RLE_DESIRED)) {
|
||||
SDL_SetSurfaceRLE(convert, SDL_RLEACCEL);
|
||||
}
|
||||
|
||||
@@ -1390,15 +1379,14 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
}
|
||||
|
||||
SDL_Surface *
|
||||
SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format,
|
||||
Uint32 flags)
|
||||
SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format)
|
||||
{
|
||||
SDL_PixelFormat *fmt;
|
||||
SDL_Surface *convert = NULL;
|
||||
|
||||
fmt = SDL_AllocFormat(pixel_format);
|
||||
if (fmt) {
|
||||
convert = SDL_ConvertSurface(surface, fmt, flags);
|
||||
convert = SDL_ConvertSurface(surface, fmt);
|
||||
SDL_FreeFormat(fmt);
|
||||
}
|
||||
return convert;
|
||||
|
Reference in New Issue
Block a user