Remove mask versions of SDL_CreateRGBSurface* #6701 (#6711)

* Rename SDL_CreateRGBSurface{,From} to SDL_CreateSurface{,From}, which now takes a format parameter
This commit is contained in:
Sylvain Becker
2022-12-01 17:04:02 +01:00
committed by GitHub
parent 778b8926b4
commit 932f61348d
36 changed files with 212 additions and 558 deletions

View File

@@ -437,8 +437,6 @@
#define SDL_iconv_close SDL_iconv_close_REAL
#define SDL_iconv SDL_iconv_REAL
#define SDL_iconv_string SDL_iconv_string_REAL
#define SDL_CreateRGBSurface SDL_CreateRGBSurface_REAL
#define SDL_CreateRGBSurfaceFrom SDL_CreateRGBSurfaceFrom_REAL
#define SDL_FreeSurface SDL_FreeSurface_REAL
#define SDL_SetSurfacePalette SDL_SetSurfacePalette_REAL
#define SDL_LockSurface SDL_LockSurface_REAL
@@ -592,8 +590,8 @@
#define SDL_RenderGetIntegerScale SDL_RenderGetIntegerScale_REAL
#define SDL_DequeueAudio SDL_DequeueAudio_REAL
#define SDL_SetWindowResizable SDL_SetWindowResizable_REAL
#define SDL_CreateRGBSurfaceWithFormat SDL_CreateRGBSurfaceWithFormat_REAL
#define SDL_CreateRGBSurfaceWithFormatFrom SDL_CreateRGBSurfaceWithFormatFrom_REAL
#define SDL_CreateSurface SDL_CreateSurface_REAL
#define SDL_CreateSurfaceFrom SDL_CreateSurfaceFrom_REAL
#define SDL_GetHintBoolean SDL_GetHintBoolean_REAL
#define SDL_JoystickGetDeviceVendor SDL_JoystickGetDeviceVendor_REAL
#define SDL_JoystickGetDeviceProduct SDL_JoystickGetDeviceProduct_REAL

View File

@@ -464,8 +464,6 @@ SDL_DYNAPI_PROC(SDL_iconv_t,SDL_iconv_open,(const char *a, const char *b),(a,b),
SDL_DYNAPI_PROC(int,SDL_iconv_close,(SDL_iconv_t a),(a),return)
SDL_DYNAPI_PROC(size_t,SDL_iconv,(SDL_iconv_t a, const char **b, size_t *c, char **d, size_t *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(char*,SDL_iconv_string,(const char *a, const char *b, const char *c, size_t d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurface,(int a, int b, int c, Uint32 d, Uint32 e, Uint32 f, Uint32 g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceFrom,(void *a, int b, int c, int d, int e, Uint32 f, Uint32 g, Uint32 h, Uint32 i),(a,b,c,d,e,f,g,h,i),return)
SDL_DYNAPI_PROC(void,SDL_FreeSurface,(SDL_Surface *a),(a),)
SDL_DYNAPI_PROC(int,SDL_SetSurfacePalette,(SDL_Surface *a, SDL_Palette *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_LockSurface,(SDL_Surface *a),(a),return)
@@ -625,8 +623,8 @@ SDL_DYNAPI_PROC(int,SDL_RenderSetIntegerScale,(SDL_Renderer *a, SDL_bool b),(a,b
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderGetIntegerScale,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(Uint32,SDL_DequeueAudio,(SDL_AudioDeviceID a, void *b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_SetWindowResizable,(SDL_Window *a, SDL_bool b),(a,b),)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormat,(int a, int b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormatFrom,(void *a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateSurface,(int a, int b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateSurfaceFrom,(void *a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetHintBoolean,(const char *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceVendor,(int a),(a),return)
SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceProduct,(int a),(a),return)

View File

@@ -1221,11 +1221,7 @@ SDL_CreateCursor(const Uint8 *data, const Uint8 *mask,
w = ((w + 7) & ~7);
/* Create the surface from a bitmap */
surface = SDL_CreateRGBSurface(w, h, 32,
0x00FF0000,
0x0000FF00,
0x000000FF,
0xFF000000);
surface = SDL_CreateSurface(w, h, SDL_PIXELFORMAT_ARGB8888);
if (surface == NULL) {
return NULL;
}

View File

@@ -2077,7 +2077,7 @@ int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect,
return ret;
}
texture->locked_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, real_rect.w, real_rect.h, pitch, texture->format);
texture->locked_surface = SDL_CreateSurfaceFrom(pixels, real_rect.w, real_rect.h, pitch, texture->format);
if (texture->locked_surface == NULL) {
SDL_UnlockTexture(texture);
return -1;

View File

@@ -377,32 +377,19 @@ int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
stretch = 1;
}
if (stretch) {
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
if (swdata->display) {
swdata->display->w = w;
swdata->display->h = h;
swdata->display->pixels = pixels;
swdata->display->pitch = pitch;
} else {
/* This must have succeeded in SDL_SW_SetupYUVDisplay() earlier */
SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask,
&Bmask, &Amask);
swdata->display =
SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask,
Gmask, Bmask, Amask);
swdata->display = SDL_CreateSurfaceFrom(pixels, w, h, pitch, target_format);
if (!swdata->display) {
return -1;
}
}
if (!swdata->stretch) {
/* This must have succeeded in SDL_SW_SetupYUVDisplay() earlier */
SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask,
&Bmask, &Amask);
swdata->stretch =
SDL_CreateRGBSurface(swdata->w, swdata->h, bpp, Rmask,
Gmask, Bmask, Amask);
swdata->stretch = SDL_CreateSurface(swdata->w, swdata->h, target_format);
if (!swdata->stretch) {
return -1;
}

View File

@@ -99,16 +99,12 @@ static int SW_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
{
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
SDL_Surface *surface = SDL_CreateSurface(texture->w, texture->h, texture->format);
if (!SDL_PixelFormatEnumToMasks(texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
return SDL_SetError("Unknown texture format");
if (surface == NULL) {
return SDL_SetError("Cannot create surface");
}
texture->driverdata =
SDL_CreateRGBSurface(texture->w, texture->h, bpp, Rmask, Gmask,
Bmask, Amask);
texture->driverdata = surface;
SDL_SetSurfaceColorMod(texture->driverdata, texture->color.r, texture->color.g, texture->color.b);
SDL_SetSurfaceAlphaMod(texture->driverdata, texture->color.a);
SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode);
@@ -116,7 +112,7 @@ static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
/* Only RLE encode textures without an alpha channel since the RLE coder
* discards the color values of pixels with an alpha value of zero.
*/
if (texture->access == SDL_TEXTUREACCESS_STATIC && !Amask) {
if (texture->access == SDL_TEXTUREACCESS_STATIC && !surface->format->Amask) {
SDL_SetSurfaceRLE(texture->driverdata, 1);
}
@@ -342,9 +338,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
/* Clone the source surface but use its pixel buffer directly.
* The original source surface must be treated as read-only.
*/
src_clone = SDL_CreateRGBSurfaceFrom(src->pixels, src->w, src->h, src->format->BitsPerPixel, src->pitch,
src->format->Rmask, src->format->Gmask,
src->format->Bmask, src->format->Amask);
src_clone = SDL_CreateSurfaceFrom(src->pixels, src->w, src->h, src->pitch, src->format->format);
if (src_clone == NULL) {
if (SDL_MUSTLOCK(src)) {
SDL_UnlockSurface(src);
@@ -387,8 +381,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
* to clear the pixels in the destination surface. The other steps are explained below.
*/
if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) {
mask = SDL_CreateRGBSurface(final_rect->w, final_rect->h, 32,
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
mask = SDL_CreateSurface(final_rect->w, final_rect->h, SDL_PIXELFORMAT_ARGB8888);
if (mask == NULL) {
retval = -1;
} else {
@@ -401,8 +394,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
*/
if (!retval && (blitRequired || applyModulation)) {
SDL_Rect scale_rect = tmp_rect;
src_scaled = SDL_CreateRGBSurface(final_rect->w, final_rect->h, 32,
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
src_scaled = SDL_CreateSurface(final_rect->w, final_rect->h, SDL_PIXELFORMAT_ARGB8888);
if (src_scaled == NULL) {
retval = -1;
} else {
@@ -482,10 +474,14 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
* to be created. This makes all source pixels opaque and the colors get copied correctly.
*/
SDL_Surface *src_rotated_rgb;
src_rotated_rgb = SDL_CreateRGBSurfaceFrom(src_rotated->pixels, src_rotated->w, src_rotated->h,
src_rotated->format->BitsPerPixel, src_rotated->pitch,
src_rotated->format->Rmask, src_rotated->format->Gmask,
src_rotated->format->Bmask, 0);
int f = SDL_MasksToPixelFormatEnum(src_rotated->format->BitsPerPixel,
src_rotated->format->Rmask,
src_rotated->format->Gmask,
src_rotated->format->Bmask,
0);
src_rotated_rgb = SDL_CreateSurfaceFrom(src_rotated->pixels, src_rotated->w, src_rotated->h,
src_rotated->pitch, f);
if (src_rotated_rgb == NULL) {
retval = -1;
} else {
@@ -816,7 +812,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
/* Prevent to do scaling + clipping on viewport boundaries as it may lose proportion */
if (dstrect->x < 0 || dstrect->y < 0 || dstrect->x + dstrect->w > surface->w || dstrect->y + dstrect->h > surface->h) {
SDL_Surface *tmp = SDL_CreateRGBSurfaceWithFormat(dstrect->w, dstrect->h, src->format->format);
SDL_Surface *tmp = SDL_CreateSurface(dstrect->w, dstrect->h, src->format->format);
/* Scale to an intermediate surface, then blit */
if (tmp) {
SDL_Rect r;

View File

@@ -523,7 +523,7 @@ SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int
rz_dst = NULL;
if (is8bit) {
/* Target surface is 8 bit */
rz_dst = SDL_CreateRGBSurfaceWithFormat(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format->format);
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format->format);
if (rz_dst != NULL) {
if (src->format->palette) {
for (i = 0; i < src->format->palette->ncolors; i++) {
@@ -534,9 +534,7 @@ SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int
}
} else {
/* Target surface is 32 bit with source RGBA ordering */
rz_dst = SDL_CreateRGBSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, 32,
src->format->Rmask, src->format->Gmask,
src->format->Bmask, src->format->Amask);
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format->format);
}
/* Check target */

View File

@@ -270,7 +270,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
}
/* Use an intermediate surface */
tmp = SDL_CreateRGBSurfaceWithFormat(dstrect.w, dstrect.h, format);
tmp = SDL_CreateSurface(dstrect.w, dstrect.h, format);
if (tmp == NULL) {
ret = -1;
goto end;

View File

@@ -1749,13 +1749,9 @@ static void SDLTest_ScreenShot(SDL_Renderer *renderer)
}
SDL_RenderGetViewport(renderer, &viewport);
surface = SDL_CreateRGBSurface(viewport.w, viewport.h, 24,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
0x00FF0000, 0x0000FF00, 0x000000FF,
#else
0x000000FF, 0x0000FF00, 0x00FF0000,
#endif
0x00000000);
surface = SDL_CreateSurface(viewport.w, viewport.h, SDL_PIXELFORMAT_BGR24);
if (surface == NULL) {
SDL_Log("Couldn't create surface: %s\n", SDL_GetError());
return;

View File

@@ -3185,8 +3185,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c)
/*
* Redraw character into surface
*/
character = SDL_CreateRGBSurface(charWidth, charHeight, 32,
0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
character = SDL_CreateSurface(charWidth, charHeight, SDL_PIXELFORMAT_RGBA8888);
if (character == NULL) {
return -1;
}

View File

@@ -540,24 +540,11 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlit = {
*/
SDL_Surface *SDLTest_ImageBlit()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
SDL_Surface *surface = SDL_CreateSurfaceFrom(
(void *)SDLTest_imageBlit.pixel_data,
SDLTest_imageBlit.width,
SDLTest_imageBlit.height,
SDLTest_imageBlit.bytes_per_pixel * 8,
SDLTest_imageBlit.width * SDLTest_imageBlit.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
SDLTest_imageBlit.width * SDLTest_imageBlit.bytes_per_pixel, SDL_PIXELFORMAT_RGB24);
return surface;
}
@@ -1025,24 +1012,11 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitColor = {
*/
SDL_Surface *SDLTest_ImageBlitColor()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
SDL_Surface *surface = SDL_CreateSurfaceFrom(
(void *)SDLTest_imageBlitColor.pixel_data,
SDLTest_imageBlitColor.width,
SDLTest_imageBlitColor.height,
SDLTest_imageBlitColor.bytes_per_pixel * 8,
SDLTest_imageBlitColor.width * SDLTest_imageBlitColor.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
SDLTest_imageBlitColor.width * SDLTest_imageBlitColor.bytes_per_pixel, SDL_PIXELFORMAT_RGB24);
return surface;
}
@@ -1673,24 +1647,11 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha = {
*/
SDL_Surface *SDLTest_ImageBlitAlpha()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
SDL_Surface *surface = SDL_CreateSurfaceFrom(
(void *)SDLTest_imageBlitAlpha.pixel_data,
SDLTest_imageBlitAlpha.width,
SDLTest_imageBlitAlpha.height,
SDLTest_imageBlitAlpha.bytes_per_pixel * 8,
SDLTest_imageBlitAlpha.width * SDLTest_imageBlitAlpha.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
SDLTest_imageBlitAlpha.width * SDLTest_imageBlitAlpha.bytes_per_pixel, SDL_PIXELFORMAT_RGB24);
return surface;
}

View File

@@ -580,24 +580,11 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = {
*/
SDL_Surface *SDLTest_ImageBlitBlendAdd()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
SDL_Surface *surface = SDL_CreateSurfaceFrom(
(void *)SDLTest_imageBlitBlendAdd.pixel_data,
SDLTest_imageBlitBlendAdd.width,
SDLTest_imageBlitBlendAdd.height,
SDLTest_imageBlitBlendAdd.bytes_per_pixel * 8,
SDLTest_imageBlitBlendAdd.width * SDLTest_imageBlitBlendAdd.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
SDLTest_imageBlitBlendAdd.width * SDLTest_imageBlitBlendAdd.bytes_per_pixel, SDL_PIXELFORMAT_RGB24);
return surface;
}
@@ -1182,24 +1169,11 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = {
*/
SDL_Surface *SDLTest_ImageBlitBlend()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
SDL_Surface *surface = SDL_CreateSurfaceFrom(
(void *)SDLTest_imageBlitBlend.pixel_data,
SDLTest_imageBlitBlend.width,
SDLTest_imageBlitBlend.height,
SDLTest_imageBlitBlend.bytes_per_pixel * 8,
SDLTest_imageBlitBlend.width * SDLTest_imageBlitBlend.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
SDLTest_imageBlitBlend.width * SDLTest_imageBlitBlend.bytes_per_pixel, SDL_PIXELFORMAT_RGB24);
return surface;
}
@@ -1614,24 +1588,11 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod = {
*/
SDL_Surface *SDLTest_ImageBlitBlendMod()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
SDL_Surface *surface = SDL_CreateSurfaceFrom(
(void *)SDLTest_imageBlitBlendMod.pixel_data,
SDLTest_imageBlitBlendMod.width,
SDLTest_imageBlitBlendMod.height,
SDLTest_imageBlitBlendMod.bytes_per_pixel * 8,
SDLTest_imageBlitBlendMod.width * SDLTest_imageBlitBlendMod.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
SDLTest_imageBlitBlendMod.width * SDLTest_imageBlitBlendMod.bytes_per_pixel, SDL_PIXELFORMAT_RGB24);
return surface;
}
@@ -2429,24 +2390,11 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone = {
*/
SDL_Surface *SDLTest_ImageBlitBlendNone()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
SDL_Surface *surface = SDL_CreateSurfaceFrom(
(void *)SDLTest_imageBlitBlendNone.pixel_data,
SDLTest_imageBlitBlendNone.width,
SDLTest_imageBlitBlendNone.height,
SDLTest_imageBlitBlendNone.bytes_per_pixel * 8,
SDLTest_imageBlitBlendNone.width * SDLTest_imageBlitBlendNone.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
SDLTest_imageBlitBlendNone.width * SDLTest_imageBlitBlendNone.bytes_per_pixel, SDL_PIXELFORMAT_RGB24);
return surface;
}
@@ -2976,24 +2924,11 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll = {
*/
SDL_Surface *SDLTest_ImageBlitBlendAll()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
SDL_Surface *surface = SDL_CreateSurfaceFrom(
(void *)SDLTest_imageBlitBlendAll.pixel_data,
SDLTest_imageBlitBlendAll.width,
SDLTest_imageBlitBlendAll.height,
SDLTest_imageBlitBlendAll.bytes_per_pixel * 8,
SDLTest_imageBlitBlendAll.width * SDLTest_imageBlitBlendAll.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
SDLTest_imageBlitBlendAll.width * SDLTest_imageBlitBlendAll.bytes_per_pixel, SDL_PIXELFORMAT_RGB24);
return surface;
}

View File

@@ -223,24 +223,12 @@ static const SDLTest_SurfaceImage_t SDLTest_imageFace = {
*/
SDL_Surface *SDLTest_ImageFace()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
SDL_Surface *surface = SDL_CreateSurfaceFrom(
(void *)SDLTest_imageFace.pixel_data,
SDLTest_imageFace.width,
SDLTest_imageFace.height,
SDLTest_imageFace.bytes_per_pixel * 8,
SDLTest_imageFace.width * SDLTest_imageFace.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
SDL_PIXELFORMAT_RGBA32);
return surface;
}

View File

@@ -504,24 +504,11 @@ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitives = {
*/
SDL_Surface *SDLTest_ImagePrimitives()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
SDL_Surface *surface = SDL_CreateSurfaceFrom(
(void *)SDLTest_imagePrimitives.pixel_data,
SDLTest_imagePrimitives.width,
SDLTest_imagePrimitives.height,
SDLTest_imagePrimitives.bytes_per_pixel * 8,
SDLTest_imagePrimitives.width * SDLTest_imagePrimitives.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
SDLTest_imagePrimitives.width * SDLTest_imagePrimitives.bytes_per_pixel, SDL_PIXELFORMAT_RGB24);
return surface;
}

View File

@@ -677,24 +677,11 @@ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitivesBlend = {
*/
SDL_Surface *SDLTest_ImagePrimitivesBlend()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
SDL_Surface *surface = SDL_CreateSurfaceFrom(
(void *)SDLTest_imagePrimitivesBlend.pixel_data,
SDLTest_imagePrimitivesBlend.width,
SDLTest_imagePrimitivesBlend.height,
SDLTest_imagePrimitivesBlend.bytes_per_pixel * 8,
SDLTest_imagePrimitivesBlend.width * SDLTest_imagePrimitivesBlend.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
SDLTest_imagePrimitivesBlend.width * SDLTest_imagePrimitivesBlend.bytes_per_pixel, SDL_PIXELFORMAT_RGB24);
return surface;
}

View File

@@ -383,16 +383,19 @@ SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
switch (biBitCount) {
case 15:
case 16:
/* SDL_PIXELFORMAT_RGB555 or SDL_PIXELFORMAT_ARGB1555 if Amask */
Rmask = 0x7C00;
Gmask = 0x03E0;
Bmask = 0x001F;
break;
case 24:
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
/* SDL_PIXELFORMAT_RGB24 */
Rmask = 0x000000FF;
Gmask = 0x0000FF00;
Bmask = 0x00FF0000;
#else
/* SDL_PIXELFORMAT_BGR24 */
Rmask = 0x00FF0000;
Gmask = 0x0000FF00;
Bmask = 0x000000FF;
@@ -401,6 +404,7 @@ SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
case 32:
/* We don't know if this has alpha channel or not */
correctAlpha = SDL_TRUE;
/* SDL_PIXELFORMAT_RGBA8888 */
Amask = 0xFF000000;
Rmask = 0x00FF0000;
Gmask = 0x0000FF00;
@@ -419,12 +423,17 @@ SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
}
/* Create a compatible surface, note that the colors are RGB ordered */
surface =
SDL_CreateRGBSurface(biWidth, biHeight, biBitCount, Rmask, Gmask,
Bmask, Amask);
if (surface == NULL) {
was_error = SDL_TRUE;
goto done;
{
Uint32 format;
/* Get the pixel format */
format = SDL_MasksToPixelFormatEnum(biBitCount, Rmask, Gmask, Bmask, Amask);
surface = SDL_CreateSurface(biWidth, biHeight, format);
if (surface == NULL) {
was_error = SDL_TRUE;
goto done;
}
}
/* Load the palette, if any */

View File

@@ -72,7 +72,7 @@ SDL_CalculatePitch(Uint32 format, size_t width, SDL_bool minimal)
* enum SDL_PIXELFORMAT_* format
*/
SDL_Surface *
SDL_CreateRGBSurfaceWithFormat(int width, int height, Uint32 format)
SDL_CreateSurface(int width, int height, Uint32 format)
{
size_t pitch;
SDL_Surface *surface;
@@ -170,82 +170,14 @@ SDL_CreateRGBSurfaceWithFormat(int width, int height, Uint32 format)
return surface;
}
/*
* Create an empty RGB surface of the appropriate depth
*/
SDL_Surface *
SDL_CreateRGBSurface(int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{
Uint32 format;
/* Get the pixel format */
format = SDL_MasksToPixelFormatEnum(depth, Rmask, Gmask, Bmask, Amask);
if (format == SDL_PIXELFORMAT_UNKNOWN) {
SDL_SetError("Unknown pixel format");
return NULL;
}
return SDL_CreateRGBSurfaceWithFormat(width, height, format);
}
/*
* Create an RGB surface from an existing memory buffer
*/
SDL_Surface *
SDL_CreateRGBSurfaceFrom(void *pixels,
int width, int height, int depth, int pitch,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
Uint32 Amask)
{
SDL_Surface *surface;
Uint32 format;
size_t minimalPitch;
if (width < 0) {
SDL_InvalidParamError("width");
return NULL;
}
if (height < 0) {
SDL_InvalidParamError("height");
return NULL;
}
format = SDL_MasksToPixelFormatEnum(depth, Rmask, Gmask, Bmask, Amask);
if (format == SDL_PIXELFORMAT_UNKNOWN) {
SDL_SetError("Unknown pixel format");
return NULL;
}
minimalPitch = SDL_CalculatePitch(format, width, SDL_TRUE);
if (pitch < 0 || (pitch > 0 && ((size_t)pitch) < minimalPitch)) {
SDL_InvalidParamError("pitch");
return NULL;
}
surface = SDL_CreateRGBSurfaceWithFormat(0, 0, format);
if (surface != NULL) {
surface->flags |= SDL_PREALLOC;
surface->pixels = pixels;
surface->w = width;
surface->h = height;
surface->pitch = pitch;
SDL_SetClipRect(surface, NULL);
}
return surface;
}
/*
* 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 pitch,
Uint32 format)
SDL_CreateSurfaceFrom(void *pixels,
int width, int height, int pitch,
Uint32 format)
{
SDL_Surface *surface;
size_t minimalPitch;
@@ -267,7 +199,7 @@ SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
return NULL;
}
surface = SDL_CreateRGBSurfaceWithFormat(0, 0, format);
surface = SDL_CreateSurface(0, 0, format);
if (surface != NULL) {
surface->flags |= SDL_PREALLOC;
surface->pixels = pixels;
@@ -1027,7 +959,7 @@ int SDL_PrivateLowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect,
} else {
fmt = SDL_PIXELFORMAT_ARGB8888;
}
tmp1 = SDL_CreateRGBSurfaceWithFormat(src->w, src->h, fmt);
tmp1 = SDL_CreateSurface(src->w, src->h, fmt);
SDL_LowerBlit(src, srcrect, tmp1, &tmprect);
srcrect2.x = 0;
@@ -1042,7 +974,7 @@ int 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(dstrect->w, dstrect->h, src->format->format);
SDL_Surface *tmp2 = SDL_CreateSurface(dstrect->w, dstrect->h, src->format->format);
SDL_SoftStretchLinear(src, &srcrect2, tmp2, NULL);
SDL_SetSurfaceColorMod(tmp2, r, g, b);
@@ -1156,10 +1088,7 @@ SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *format)
}
/* Create a new surface with the desired format */
convert = SDL_CreateRGBSurface(surface->w, surface->h,
format->BitsPerPixel, format->Rmask,
format->Gmask, format->Bmask,
format->Amask);
convert = SDL_CreateSurface(surface->w, surface->h, format->format);
if (convert == NULL) {
return NULL;
}
@@ -1300,10 +1229,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(1, 1,
surface->format->BitsPerPixel, surface->format->Rmask,
surface->format->Gmask, surface->format->Bmask,
surface->format->Amask);
tmp = SDL_CreateSurface(1, 1, surface->format->format);
/* Share the palette, if any */
if (surface->format->palette) {

View File

@@ -2556,8 +2556,6 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
Uint32 format = 0;
void *pixels = NULL;
int pitch = 0;
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
SDL_bool created_framebuffer = SDL_FALSE;
/* This will switch the video backend from using a software surface to
@@ -2633,11 +2631,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
return window->surface;
}
if (!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
return NULL;
}
return SDL_CreateRGBSurfaceFrom(pixels, window->w, window->h, bpp, pitch, Rmask, Gmask, Bmask, Amask);
return SDL_CreateSurfaceFrom(pixels, window->w, window->h, pitch, format);
}
SDL_Surface *

View File

@@ -118,7 +118,7 @@ static void Android_FreeCursor(SDL_Cursor *cursor)
static SDL_Cursor *Android_CreateEmptyCursor()
{
if (empty_cursor == NULL) {
SDL_Surface *empty_surface = SDL_CreateRGBSurfaceWithFormat(1, 1, SDL_PIXELFORMAT_ARGB8888);
SDL_Surface *empty_surface = SDL_CreateSurface(1, 1, SDL_PIXELFORMAT_ARGB8888);
if (empty_surface) {
SDL_memset(empty_surface->pixels, 0, empty_surface->h * empty_surface->pitch);
empty_cursor = Android_CreateCursor(empty_surface, 0, 0);

View File

@@ -38,7 +38,7 @@ int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format,
/* Create a new one */
SDL_GetWindowSize(window, &w, &h);
surface = SDL_CreateRGBSurfaceWithFormat(w, h, surface_format);
surface = SDL_CreateSurface(w, h, surface_format);
if (surface == NULL) {
return -1;
}

View File

@@ -32,8 +32,6 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_BGR888;
int w, h;
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
/* Free the old framebuffer surface */
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
@@ -41,10 +39,9 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format
SDL_FreeSurface(surface);
/* Create a new one */
SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
SDL_GetWindowSize(window, &w, &h);
surface = SDL_CreateRGBSurface(w, h, bpp, Rmask, Gmask, Bmask, Amask);
surface = SDL_CreateSurface(w, h, surface_format);
if (surface == NULL) {
return -1;
}

View File

@@ -68,11 +68,9 @@ FreePreviousWindowFramebuffer(SDL_Window *window)
SDL_FORCE_INLINE SDL_Surface *
CreateNewWindowFramebuffer(SDL_Window *window)
{
int w, h, bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
SDL_PixelFormatEnumToMasks(FRAMEBUFFER_FORMAT, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
int w, h;
SDL_GetWindowSize(window, &w, &h);
return SDL_CreateRGBSurface(w, h, bpp, Rmask, Gmask, Bmask, Amask);
return SDL_CreateSurface(w, h, FRAMEBUFFER_FORMAT);
}
int SDL_N3DS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)

View File

@@ -56,7 +56,7 @@ int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format,
/* Create a new one */
SDL_GetWindowSize(window, &w, &h);
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
surface = SDL_CreateSurface(w, h, surface_format);
if (surface == NULL) {
return -1;
}

View File

@@ -38,7 +38,7 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *for
/* Create a new one */
SDL_GetWindowSize(window, &w, &h);
surface = SDL_CreateRGBSurfaceWithFormat(w, h, surface_format);
surface = SDL_CreateSurface(w, h, surface_format);
if (surface == NULL) {
return -1;
}

View File

@@ -170,7 +170,7 @@ static SDL_Cursor *WIN_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y)
static SDL_Cursor *WIN_CreateBlankCursor()
{
SDL_Cursor *cursor = NULL;
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(32, 32, SDL_PIXELFORMAT_ARGB8888);
SDL_Surface *surface = SDL_CreateSurface(32, 32, SDL_PIXELFORMAT_ARGB8888);
if (surface) {
cursor = WIN_CreateCursor(surface, 0, 0);
SDL_FreeSurface(surface);