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:
Sylvain Becker 2022-11-29 18:40:09 +01:00 committed by GitHub
parent 6873082c34
commit fc4fc5295f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 95 additions and 109 deletions

View file

@ -25,3 +25,7 @@ General:
* SDL_HINT_VIDEO_X11_XINERAMA * SDL_HINT_VIDEO_X11_XINERAMA
* SDL_HINT_VIDEO_X11_XVIDMODE * SDL_HINT_VIDEO_X11_XVIDMODE
* SDL_stdinc.h no longer includes stdio.h, stdlib.h, etc., it only provides the SDL C runtime functionality * SDL_stdinc.h no longer includes stdio.h, stdlib.h, etc., it only provides the SDL C runtime functionality
* Removed unused 'depth' parameter 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

View file

@ -343,7 +343,7 @@ initializeTexture()
&Bmask, &Amask); &Bmask, &Amask);
/* Create surface that will hold pixels passed into OpenGL */ /* Create surface that will hold pixels passed into OpenGL */
bmp_surface_rgba8888 = bmp_surface_rgba8888 =
SDL_CreateRGBSurface(0, bmp_surface->w, bmp_surface->h, bpp, Rmask, SDL_CreateRGBSurface(bmp_surface->w, bmp_surface->h, bpp, Rmask,
Gmask, Bmask, Amask); Gmask, Bmask, Amask);
/* Blit to this surface, effectively converting the format */ /* Blit to this surface, effectively converting the format */
SDL_BlitSurface(bmp_surface, NULL, bmp_surface_rgba8888, NULL); SDL_BlitSurface(bmp_surface, NULL, bmp_surface_rgba8888, NULL);

View file

@ -178,7 +178,7 @@ loadFont(void)
SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask,
&Amask); &Amask);
SDL_Surface *converted = SDL_Surface *converted =
SDL_CreateRGBSurface(0, surface->w, surface->h, bpp, Rmask, Gmask, SDL_CreateRGBSurface(surface->w, surface->h, bpp, Rmask, Gmask,
Bmask, Amask); Bmask, Amask);
SDL_BlitSurface(surface, NULL, converted, NULL); SDL_BlitSurface(surface, NULL, converted, NULL);
/* create our texture */ /* create our texture */

View file

@ -160,6 +160,13 @@ The standard C headers like stdio.h and stdlib.h are no longer included, you sho
M_PI is no longer defined in SDL_stdinc.h, you can use the new symbols SDL_PI_D (double) and SDL_PI_F (float) instead. M_PI is no longer defined in SDL_stdinc.h, you can use the new symbols SDL_PI_D (double) and SDL_PI_F (float) instead.
## SDL_surface.h
Removed unused 'depth' parameter 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
## SDL_syswm.h ## SDL_syswm.h
This header no longer includes platform specific headers and type definitions, instead allowing you to include the ones appropriate for your use case. You should define one or more of the following to enable the relevant platform-specific support: This header no longer includes platform specific headers and type definitions, instead allowing you to include the ones appropriate for your use case. You should define one or more of the following to enable the relevant platform-specific support:

View file

@ -140,7 +140,6 @@ typedef enum
* You can change this by calling SDL_SetSurfaceBlendMode() and selecting a * You can change this by calling SDL_SetSurfaceBlendMode() and selecting a
* different `blendMode`. * different `blendMode`.
* *
* \param flags the flags are unused and should be set to 0
* \param width the width of the surface * \param width the width of the surface
* \param height the height of the surface * \param height the height of the surface
* \param depth the depth of the surface in bits * \param depth the depth of the surface in bits
@ -158,12 +157,10 @@ typedef enum
* \sa SDL_FreeSurface * \sa SDL_FreeSurface
*/ */
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
(Uint32 flags, int width, int height, int depth, (int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
/* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
/** /**
* Allocate a new RGB surface with a specific pixel format. * Allocate a new RGB surface with a specific pixel format.
* *
@ -171,10 +168,8 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
* of providing pixel color masks, you provide it with a predefined format * of providing pixel color masks, you provide it with a predefined format
* from SDL_PixelFormatEnum. * from SDL_PixelFormatEnum.
* *
* \param flags the flags are unused and should be set to 0
* \param width the width of the surface * \param width the width of the surface
* \param height the height of the surface * \param height the height of the surface
* \param depth the depth of the surface in bits
* \param format the SDL_PixelFormatEnum for the new surface's pixel format. * \param format the SDL_PixelFormatEnum for the new surface's pixel format.
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
@ -186,7 +181,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
* \sa SDL_FreeSurface * \sa SDL_FreeSurface
*/ */
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat
(Uint32 flags, int width, int height, int depth, Uint32 format); (int width, int height, Uint32 format);
/** /**
* Allocate a new RGB surface with existing pixel data. * Allocate a new RGB surface with existing pixel data.
@ -226,8 +221,6 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
Uint32 Bmask, Uint32 Bmask,
Uint32 Amask); Uint32 Amask);
/* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
/** /**
* Allocate a new RGB surface with with a specific pixel format and existing * Allocate a new RGB surface with with a specific pixel format and existing
* pixel data. * pixel data.
@ -242,7 +235,6 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
* \param pixels a pointer to existing pixel data * \param pixels a pointer to existing pixel data
* \param width the width of the surface * \param width the width of the surface
* \param height the height of the surface * \param height the height of the surface
* \param depth the depth of the surface in bits
* \param pitch the pitch of the surface in bytes * \param pitch the pitch of the surface in bytes
* \param format the SDL_PixelFormatEnum for the new surface's pixel format. * \param format the SDL_PixelFormatEnum for the new surface's pixel format.
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
@ -255,7 +247,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
* \sa SDL_FreeSurface * \sa SDL_FreeSurface
*/ */
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormatFrom extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormatFrom
(void *pixels, int width, int height, int depth, int pitch, Uint32 format); (void *pixels, int width, int height, int pitch, Uint32 format);
/** /**
* Free an RGB surface. * Free an RGB surface.
@ -661,8 +653,6 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface)
* \param src the existing SDL_Surface structure to convert * \param src the existing SDL_Surface structure to convert
* \param fmt the SDL_PixelFormat structure that the new surface is optimized * \param fmt the SDL_PixelFormat structure that the new surface is optimized
* for * for
* \param flags the flags are unused and should be set to 0; this is a
* leftover from SDL 1.2's API
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
@ -673,7 +663,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface)
* \sa SDL_CreateRGBSurface * \sa SDL_CreateRGBSurface
*/ */
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
(SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags); (SDL_Surface * src, const SDL_PixelFormat * fmt);
/** /**
* Copy an existing surface to a new surface of the specified format enum. * Copy an existing surface to a new surface of the specified format enum.
@ -686,8 +676,6 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
* \param src the existing SDL_Surface structure to convert * \param src the existing SDL_Surface structure to convert
* \param pixel_format the SDL_PixelFormatEnum that the new surface is * \param pixel_format the SDL_PixelFormatEnum that the new surface is
* optimized for * optimized for
* \param flags the flags are unused and should be set to 0; this is a
* leftover from SDL 1.2's API
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
@ -698,7 +686,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
* \sa SDL_CreateRGBSurface * \sa SDL_CreateRGBSurface
*/ */
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
(SDL_Surface * src, Uint32 pixel_format, Uint32 flags); (SDL_Surface * src, Uint32 pixel_format);
/** /**
* Copy a block of pixels of one format to another format. * Copy a block of pixels of one format to another format.

View file

@ -464,7 +464,7 @@ 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(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(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(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,(Uint32 a, int b, int c, int d, Uint32 e, Uint32 f, Uint32 g, Uint32 h),(a,b,c,d,e,f,g,h),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(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(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_SetSurfacePalette,(SDL_Surface *a, SDL_Palette *b),(a,b),return)
@ -483,8 +483,8 @@ SDL_DYNAPI_PROC(int,SDL_SetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode b),(a
SDL_DYNAPI_PROC(int,SDL_GetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_SetClipRect,(SDL_Surface *a, const SDL_Rect *b),(a,b),return) SDL_DYNAPI_PROC(SDL_bool,SDL_SetClipRect,(SDL_Surface *a, const SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_GetClipRect,(SDL_Surface *a, SDL_Rect *b),(a,b),) SDL_DYNAPI_PROC(void,SDL_GetClipRect,(SDL_Surface *a, SDL_Rect *b),(a,b),)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurface,(SDL_Surface *a, const SDL_PixelFormat *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurface,(SDL_Surface *a, const SDL_PixelFormat *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurfaceFormat,(SDL_Surface *a, Uint32 b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurfaceFormat,(SDL_Surface *a, Uint32 b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_ConvertPixels,(int a, int b, Uint32 c, const void *d, int e, Uint32 f, void *g, int h),(a,b,c,d,e,f,g,h),return) SDL_DYNAPI_PROC(int,SDL_ConvertPixels,(int a, int b, Uint32 c, const void *d, int e, Uint32 f, void *g, int h),(a,b,c,d,e,f,g,h),return)
SDL_DYNAPI_PROC(int,SDL_FillRect,(SDL_Surface *a, const SDL_Rect *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_FillRect,(SDL_Surface *a, const SDL_Rect *b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_FillRects,(SDL_Surface *a, const SDL_Rect *b, int c, Uint32 d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_FillRects,(SDL_Surface *a, const SDL_Rect *b, int c, Uint32 d),(a,b,c,d),return)
@ -625,8 +625,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(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(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(void,SDL_SetWindowResizable,(SDL_Window *a, SDL_bool b),(a,b),)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormat,(Uint32 a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return) 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, int e, Uint32 f),(a,b,c,d,e,f),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_bool,SDL_GetHintBoolean,(const char *a, SDL_bool b),(a,b),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_JoystickGetDeviceVendor,(int a),(a),return)
SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceProduct,(int a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceProduct,(int a),(a),return)

View file

@ -1254,7 +1254,7 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
w = ((w + 7) & ~7); w = ((w + 7) & ~7);
/* Create the surface from a bitmap */ /* Create the surface from a bitmap */
surface = SDL_CreateRGBSurface(0, w, h, 32, surface = SDL_CreateRGBSurface(w, h, 32,
0x00FF0000, 0x00FF0000,
0x0000FF00, 0x0000FF00,
0x000000FF, 0x000000FF,
@ -1311,7 +1311,7 @@ SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
} }
if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) { if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) {
temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888);
if (temp == NULL) { if (temp == NULL) {
return NULL; return NULL;
} }

View file

@ -1485,7 +1485,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
SDL_DestroyTexture(texture); SDL_DestroyTexture(texture);
return NULL; return NULL;
} }
temp = SDL_ConvertSurface(surface, dst_fmt, 0); temp = SDL_ConvertSurface(surface, dst_fmt);
SDL_FreeFormat(dst_fmt); SDL_FreeFormat(dst_fmt);
if (temp) { if (temp) {
SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch); SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch);
@ -2131,7 +2131,7 @@ SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect,
return ret; return ret;
} }
texture->locked_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, real_rect.w, real_rect.h, 0, pitch, texture->format); texture->locked_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, real_rect.w, real_rect.h, pitch, texture->format);
if (texture->locked_surface == NULL) { if (texture->locked_surface == NULL) {
SDL_UnlockTexture(texture); SDL_UnlockTexture(texture);
return -1; return -1;

View file

@ -413,7 +413,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask, SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask,
&Bmask, &Amask); &Bmask, &Amask);
swdata->stretch = swdata->stretch =
SDL_CreateRGBSurface(0, swdata->w, swdata->h, bpp, Rmask, SDL_CreateRGBSurface(swdata->w, swdata->h, bpp, Rmask,
Gmask, Bmask, Amask); Gmask, Bmask, Amask);
if (!swdata->stretch) { if (!swdata->stretch) {
return -1; return -1;

View file

@ -113,7 +113,7 @@ SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
} }
texture->driverdata = texture->driverdata =
SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask, SDL_CreateRGBSurface(texture->w, texture->h, bpp, Rmask, Gmask,
Bmask, Amask); Bmask, Amask);
SDL_SetSurfaceColorMod(texture->driverdata, texture->color.r, texture->color.g, texture->color.b); SDL_SetSurfaceColorMod(texture->driverdata, texture->color.r, texture->color.g, texture->color.b);
SDL_SetSurfaceAlphaMod(texture->driverdata, texture->color.a); SDL_SetSurfaceAlphaMod(texture->driverdata, texture->color.a);
@ -405,7 +405,7 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
* to clear the pixels in the destination surface. The other steps are explained below. * to clear the pixels in the destination surface. The other steps are explained below.
*/ */
if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) { if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) {
mask = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32, mask = SDL_CreateRGBSurface(final_rect->w, final_rect->h, 32,
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
if (mask == NULL) { if (mask == NULL) {
retval = -1; retval = -1;
@ -419,7 +419,7 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
*/ */
if (!retval && (blitRequired || applyModulation)) { if (!retval && (blitRequired || applyModulation)) {
SDL_Rect scale_rect = tmp_rect; SDL_Rect scale_rect = tmp_rect;
src_scaled = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32, src_scaled = SDL_CreateRGBSurface(final_rect->w, final_rect->h, 32,
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
if (src_scaled == NULL) { if (src_scaled == NULL) {
retval = -1; retval = -1;
@ -831,7 +831,7 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
/* Prevent to do scaling + clipping on viewport boundaries as it may lose proportion */ /* 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) { if (dstrect->x < 0 || dstrect->y < 0 || dstrect->x + dstrect->w > surface->w || dstrect->y + dstrect->h > surface->h) {
SDL_Surface *tmp = SDL_CreateRGBSurfaceWithFormat(0, dstrect->w, dstrect->h, 0, src->format->format); SDL_Surface *tmp = SDL_CreateRGBSurfaceWithFormat(dstrect->w, dstrect->h, src->format->format);
/* Scale to an intermediate surface, then blit */ /* Scale to an intermediate surface, then blit */
if (tmp) { if (tmp) {
SDL_Rect r; SDL_Rect r;

View file

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

View file

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

View file

@ -1766,7 +1766,7 @@ SDLTest_ScreenShot(SDL_Renderer *renderer)
} }
SDL_RenderGetViewport(renderer, &viewport); SDL_RenderGetViewport(renderer, &viewport);
surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, surface = SDL_CreateRGBSurface(viewport.w, viewport.h, 24,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN #if SDL_BYTEORDER == SDL_LIL_ENDIAN
0x00FF0000, 0x0000FF00, 0x000000FF, 0x00FF0000, 0x0000FF00, 0x000000FF,
#else #else

View file

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

View file

@ -417,7 +417,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
/* Create a compatible surface, note that the colors are RGB ordered */ /* Create a compatible surface, note that the colors are RGB ordered */
surface = surface =
SDL_CreateRGBSurface(0, biWidth, biHeight, biBitCount, Rmask, Gmask, SDL_CreateRGBSurface(biWidth, biHeight, biBitCount, Rmask, Gmask,
Bmask, Amask); Bmask, Amask);
if (surface == NULL) { if (surface == NULL) {
was_error = SDL_TRUE; was_error = SDL_TRUE;
@ -689,7 +689,7 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst)
} else { } else {
SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24); SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24);
} }
surface = SDL_ConvertSurface(saveme, &format, 0); surface = SDL_ConvertSurface(saveme, &format);
if (surface == NULL) { if (surface == NULL) {
SDL_SetError("Couldn't convert image to %d bpp", SDL_SetError("Couldn't convert image to %d bpp",
format.BitsPerPixel); format.BitsPerPixel);

View file

@ -68,21 +68,16 @@ SDL_CalculatePitch(Uint32 format, size_t width, SDL_bool minimal)
return pitch; 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 * Create an empty RGB surface of the appropriate depth using the given
* enum SDL_PIXELFORMAT_* format * enum SDL_PIXELFORMAT_* format
*/ */
SDL_Surface * SDL_Surface *
SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, SDL_CreateRGBSurfaceWithFormat(int width, int height, Uint32 format)
Uint32 format)
{ {
size_t pitch; size_t pitch;
SDL_Surface *surface; SDL_Surface *surface;
/* The flags are no longer used, make the compiler happy */
(void)flags;
if (width < 0) { if (width < 0) {
SDL_InvalidParamError("width"); SDL_InvalidParamError("width");
return NULL; return NULL;
@ -176,13 +171,11 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
return surface; return surface;
} }
/* TODO: In SDL 3, drop the unused flags parameter */
/* /*
* Create an empty RGB surface of the appropriate depth * Create an empty RGB surface of the appropriate depth
*/ */
SDL_Surface * SDL_Surface *
SDL_CreateRGBSurface(Uint32 flags, SDL_CreateRGBSurface(int width, int height, int depth,
int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{ {
Uint32 format; Uint32 format;
@ -194,7 +187,7 @@ SDL_CreateRGBSurface(Uint32 flags,
return NULL; 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; return NULL;
} }
surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format); surface = SDL_CreateRGBSurfaceWithFormat(0, 0, format);
if (surface != NULL) { if (surface != NULL) {
surface->flags |= SDL_PREALLOC; surface->flags |= SDL_PREALLOC;
surface->pixels = pixels; surface->pixels = pixels;
@ -246,14 +239,13 @@ SDL_CreateRGBSurfaceFrom(void *pixels,
return surface; return surface;
} }
/* TODO: In SDL 3, drop the unused depth parameter */
/* /*
* Create an RGB surface from an existing memory buffer using the given given * Create an RGB surface from an existing memory buffer using the given given
* enum SDL_PIXELFORMAT_* format * enum SDL_PIXELFORMAT_* format
*/ */
SDL_Surface * SDL_Surface *
SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
int width, int height, int depth, int pitch, int width, int height, int pitch,
Uint32 format) Uint32 format)
{ {
SDL_Surface *surface; SDL_Surface *surface;
@ -276,7 +268,7 @@ SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
return NULL; return NULL;
} }
surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format); surface = SDL_CreateRGBSurfaceWithFormat(0, 0, format);
if (surface != NULL) { if (surface != NULL) {
surface->flags |= SDL_PREALLOC; surface->flags |= SDL_PREALLOC;
surface->pixels = pixels; surface->pixels = pixels;
@ -1034,13 +1026,11 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
SDL_Rect srcrect2; SDL_Rect srcrect2;
int is_complex_copy_flags = (src->map->info.flags & complex_copy_flags); int is_complex_copy_flags = (src->map->info.flags & complex_copy_flags);
Uint32 flags;
Uint8 r, g, b; Uint8 r, g, b;
Uint8 alpha; Uint8 alpha;
SDL_BlendMode blendMode; SDL_BlendMode blendMode;
/* Save source infos */ /* Save source infos */
flags = src->flags;
SDL_GetSurfaceColorMod(src, &r, &g, &b); SDL_GetSurfaceColorMod(src, &r, &g, &b);
SDL_GetSurfaceAlphaMod(src, &alpha); SDL_GetSurfaceAlphaMod(src, &alpha);
SDL_GetSurfaceBlendMode(src, &blendMode); SDL_GetSurfaceBlendMode(src, &blendMode);
@ -1062,7 +1052,7 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
} else { } else {
fmt = SDL_PIXELFORMAT_ARGB8888; 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); SDL_LowerBlit(src, srcrect, tmp1, &tmprect);
@ -1078,7 +1068,7 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
/* Intermediate scaling */ /* Intermediate scaling */
if (is_complex_copy_flags || src->format->format != dst->format->format) { if (is_complex_copy_flags || src->format->format != dst->format->format) {
SDL_Rect tmprect; 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_SoftStretchLinear(src, &srcrect2, tmp2, NULL);
SDL_SetSurfaceColorMod(tmp2, r, g, b); SDL_SetSurfaceColorMod(tmp2, r, g, b);
@ -1150,15 +1140,14 @@ SDL_UnlockSurface(SDL_Surface * surface)
SDL_Surface * SDL_Surface *
SDL_DuplicateSurface(SDL_Surface * 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. * Convert a surface into the specified pixel format.
*/ */
SDL_Surface * SDL_Surface *
SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format, SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format)
Uint32 flags)
{ {
SDL_Surface *convert; SDL_Surface *convert;
Uint32 copy_flags; Uint32 copy_flags;
@ -1195,7 +1184,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
} }
/* Create a new surface with the desired 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->BitsPerPixel, format->Rmask,
format->Gmask, format->Bmask, format->Gmask, format->Bmask,
format->Amask); format->Amask);
@ -1340,7 +1329,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
int converted_colorkey = 0; int converted_colorkey = 0;
/* Create a dummy surface to get the colorkey converted */ /* 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->BitsPerPixel, surface->format->Rmask,
surface->format->Gmask, surface->format->Bmask, surface->format->Gmask, surface->format->Bmask,
surface->format->Amask); surface->format->Amask);
@ -1355,7 +1344,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
tmp->map->info.flags &= ~SDL_COPY_COLORKEY; tmp->map->info.flags &= ~SDL_COPY_COLORKEY;
/* Convertion of the colorkey */ /* Convertion of the colorkey */
tmp2 = SDL_ConvertSurface(tmp, format, 0); tmp2 = SDL_ConvertSurface(tmp, format);
/* Get the converted colorkey */ /* Get the converted colorkey */
SDL_memcpy(&converted_colorkey, tmp2->pixels, tmp2->format->BytesPerPixel); 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)) { (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
SDL_SetSurfaceBlendMode(convert, SDL_BLENDMODE_BLEND); 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); SDL_SetSurfaceRLE(convert, SDL_RLEACCEL);
} }
@ -1390,15 +1379,14 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
} }
SDL_Surface * SDL_Surface *
SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format, SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format)
Uint32 flags)
{ {
SDL_PixelFormat *fmt; SDL_PixelFormat *fmt;
SDL_Surface *convert = NULL; SDL_Surface *convert = NULL;
fmt = SDL_AllocFormat(pixel_format); fmt = SDL_AllocFormat(pixel_format);
if (fmt) { if (fmt) {
convert = SDL_ConvertSurface(surface, fmt, flags); convert = SDL_ConvertSurface(surface, fmt);
SDL_FreeFormat(fmt); SDL_FreeFormat(fmt);
} }
return convert; return convert;

View file

@ -2065,7 +2065,7 @@ SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon)
SDL_FreeSurface(window->icon); SDL_FreeSurface(window->icon);
/* Convert the icon into ARGB8888 */ /* Convert the icon into ARGB8888 */
window->icon = SDL_ConvertSurfaceFormat(icon, SDL_PIXELFORMAT_ARGB8888, 0); window->icon = SDL_ConvertSurfaceFormat(icon, SDL_PIXELFORMAT_ARGB8888);
if (!window->icon) { if (!window->icon) {
return; return;
} }

View file

@ -90,7 +90,7 @@ Android_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
int custom_cursor; int custom_cursor;
SDL_Surface *converted; SDL_Surface *converted;
converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888);
if (converted == NULL) { if (converted == NULL) {
return NULL; return NULL;
} }
@ -124,7 +124,7 @@ static SDL_Cursor *
Android_CreateEmptyCursor() Android_CreateEmptyCursor()
{ {
if (empty_cursor == NULL) { if (empty_cursor == NULL) {
SDL_Surface *empty_surface = SDL_CreateRGBSurfaceWithFormat(0, 1, 1, 32, SDL_PIXELFORMAT_ARGB8888); SDL_Surface *empty_surface = SDL_CreateRGBSurfaceWithFormat(1, 1, SDL_PIXELFORMAT_ARGB8888);
if (empty_surface) { if (empty_surface) {
SDL_memset(empty_surface->pixels, 0, empty_surface->h * empty_surface->pitch); SDL_memset(empty_surface->pixels, 0, empty_surface->h * empty_surface->pitch);
empty_cursor = Android_CreateCursor(empty_surface, 0, 0); empty_cursor = Android_CreateCursor(empty_surface, 0, 0);

View file

@ -236,7 +236,7 @@ Cocoa_CreateImage(SDL_Surface * surface)
int i; int i;
NSImage *img; NSImage *img;
converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_RGBA32, 0); converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_RGBA32);
if (!converted) { if (!converted) {
return nil; return nil;
} }

View file

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

View file

@ -45,7 +45,7 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * form
SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
SDL_GetWindowSize(window, &w, &h); SDL_GetWindowSize(window, &w, &h);
surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask); surface = SDL_CreateRGBSurface(w, h, bpp, Rmask, Gmask, Bmask, Amask);
if (surface == NULL) { if (surface == NULL) {
return -1; return -1;
} }

View file

@ -69,7 +69,7 @@ Emscripten_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y)
const char *cursor_url = NULL; const char *cursor_url = NULL;
SDL_Surface *conv_surf; SDL_Surface *conv_surf;
conv_surf = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ABGR8888, 0); conv_surf = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ABGR8888);
if (conv_surf == NULL) { if (conv_surf == NULL) {
return NULL; return NULL;

View file

@ -73,7 +73,7 @@ CreateNewWindowFramebuffer(SDL_Window *window)
Uint32 Rmask, Gmask, Bmask, Amask; Uint32 Rmask, Gmask, Bmask, Amask;
SDL_PixelFormatEnumToMasks(FRAMEBUFFER_FORMAT, &bpp, &Rmask, &Gmask, &Bmask, &Amask); SDL_PixelFormatEnumToMasks(FRAMEBUFFER_FORMAT, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
SDL_GetWindowSize(window, &w, &h); SDL_GetWindowSize(window, &w, &h);
return SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask); return SDL_CreateRGBSurface(w, h, bpp, Rmask, Gmask, Bmask, Amask);
} }
int int

View file

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

View file

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

View file

@ -55,7 +55,7 @@ _surfaceSetUp(void *arg)
#endif #endif
referenceSurface = SDLTest_ImageBlit(); /* For size info */ referenceSurface = SDLTest_ImageBlit(); /* For size info */
testSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, referenceSurface->w, referenceSurface->h, 32, rmask, gmask, bmask, amask); testSurface = SDL_CreateRGBSurface(referenceSurface->w, referenceSurface->h, 32, rmask, gmask, bmask, amask);
SDLTest_AssertCheck(testSurface != NULL, "Check that testSurface is not NULL"); SDLTest_AssertCheck(testSurface != NULL, "Check that testSurface is not NULL");
if (testSurface != NULL) { if (testSurface != NULL) {
/* Disable blend mode for target surface */ /* Disable blend mode for target surface */
@ -299,7 +299,7 @@ surface_testSurfaceConversion(void *arg)
} }
/* Convert to 32 bit to compare. */ /* Convert to 32 bit to compare. */
rface = SDL_ConvertSurface( face, testSurface->format, 0 ); rface = SDL_ConvertSurface( face, testSurface->format);
SDLTest_AssertPass("Call to SDL_ConvertSurface()"); SDLTest_AssertPass("Call to SDL_ConvertSurface()");
SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_ConvertSurface is not NULL"); SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_ConvertSurface is not NULL");
@ -374,19 +374,19 @@ surface_testCompleteSurfaceConversion(void *arg)
for ( j = 0; j < SDL_arraysize(pixel_formats); ++j ) { for ( j = 0; j < SDL_arraysize(pixel_formats); ++j ) {
fmt1 = SDL_AllocFormat(pixel_formats[i]); fmt1 = SDL_AllocFormat(pixel_formats[i]);
SDL_assert(fmt1 != NULL); SDL_assert(fmt1 != NULL);
cvt1 = SDL_ConvertSurface(face, fmt1, 0); cvt1 = SDL_ConvertSurface(face, fmt1);
SDL_assert(cvt1 != NULL); SDL_assert(cvt1 != NULL);
fmt2 = SDL_AllocFormat(pixel_formats[j]); fmt2 = SDL_AllocFormat(pixel_formats[j]);
SDL_assert(fmt1 != NULL); SDL_assert(fmt1 != NULL);
cvt2 = SDL_ConvertSurface(cvt1, fmt2, 0); cvt2 = SDL_ConvertSurface(cvt1, fmt2);
SDL_assert(cvt2 != NULL); SDL_assert(cvt2 != NULL);
if ( fmt1->BytesPerPixel == face->format->BytesPerPixel && if ( fmt1->BytesPerPixel == face->format->BytesPerPixel &&
fmt2->BytesPerPixel == face->format->BytesPerPixel && fmt2->BytesPerPixel == face->format->BytesPerPixel &&
(fmt1->Amask != 0) == (face->format->Amask != 0) && (fmt1->Amask != 0) == (face->format->Amask != 0) &&
(fmt2->Amask != 0) == (face->format->Amask != 0) ) { (fmt2->Amask != 0) == (face->format->Amask != 0) ) {
final = SDL_ConvertSurface( cvt2, face->format, 0 ); final = SDL_ConvertSurface( cvt2, face->format);
SDL_assert(final != NULL); SDL_assert(final != NULL);
/* Compare surface. */ /* Compare surface. */
@ -617,11 +617,11 @@ surface_testOverflow(void *arg)
SDL_memset(buf, '\0', sizeof(buf)); SDL_memset(buf, '\0', sizeof(buf));
expectedError = "Parameter 'width' is invalid"; expectedError = "Parameter 'width' is invalid";
surface = SDL_CreateRGBSurfaceWithFormat(0, -3, 100, 8, SDL_PIXELFORMAT_INDEX8); surface = SDL_CreateRGBSurfaceWithFormat(-3, 100, SDL_PIXELFORMAT_INDEX8);
SDLTest_AssertCheck(surface == NULL, "Should detect negative width"); SDLTest_AssertCheck(surface == NULL, "Should detect negative width");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, -1, 1, 8, 4, SDL_PIXELFORMAT_INDEX8); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, -1, 1, 4, SDL_PIXELFORMAT_INDEX8);
SDLTest_AssertCheck(surface == NULL, "Should detect negative width"); SDLTest_AssertCheck(surface == NULL, "Should detect negative width");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
@ -631,11 +631,11 @@ surface_testOverflow(void *arg)
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
expectedError = "Parameter 'height' is invalid"; expectedError = "Parameter 'height' is invalid";
surface = SDL_CreateRGBSurfaceWithFormat(0, 100, -3, 8, SDL_PIXELFORMAT_INDEX8); surface = SDL_CreateRGBSurfaceWithFormat(100, -3, SDL_PIXELFORMAT_INDEX8);
SDLTest_AssertCheck(surface == NULL, "Should detect negative height"); SDLTest_AssertCheck(surface == NULL, "Should detect negative height");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 1, -1, 8, 4, SDL_PIXELFORMAT_INDEX8); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 1, -1, 4, SDL_PIXELFORMAT_INDEX8);
SDLTest_AssertCheck(surface == NULL, "Should detect negative height"); SDLTest_AssertCheck(surface == NULL, "Should detect negative height");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
@ -645,7 +645,7 @@ surface_testOverflow(void *arg)
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
expectedError = "Parameter 'pitch' is invalid"; expectedError = "Parameter 'pitch' is invalid";
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 4, 1, 8, -1, SDL_PIXELFORMAT_INDEX8); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 4, 1, -1, SDL_PIXELFORMAT_INDEX8);
SDLTest_AssertCheck(surface == NULL, "Should detect negative pitch"); SDLTest_AssertCheck(surface == NULL, "Should detect negative pitch");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
@ -657,7 +657,7 @@ surface_testOverflow(void *arg)
/* Less than 1 byte per pixel: the pitch can legitimately be less than /* Less than 1 byte per pixel: the pitch can legitimately be less than
* the width, but it must be enough to hold the appropriate number of * the width, but it must be enough to hold the appropriate number of
* bits per pixel. SDL_PIXELFORMAT_INDEX4* needs 1 byte per 2 pixels. */ * bits per pixel. SDL_PIXELFORMAT_INDEX4* needs 1 byte per 2 pixels. */
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 6, 1, 4, 3, SDL_PIXELFORMAT_INDEX4LSB); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 6, 1, 3, SDL_PIXELFORMAT_INDEX4LSB);
SDLTest_AssertCheck(surface != NULL, "6px * 4 bits per px fits in 3 bytes: %s", SDLTest_AssertCheck(surface != NULL, "6px * 4 bits per px fits in 3 bytes: %s",
surface != NULL ? "(success)" : SDL_GetError()); surface != NULL ? "(success)" : SDL_GetError());
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
@ -666,7 +666,7 @@ surface_testOverflow(void *arg)
surface != NULL ? "(success)" : SDL_GetError()); surface != NULL ? "(success)" : SDL_GetError());
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 7, 1, 4, 3, SDL_PIXELFORMAT_INDEX4LSB); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 7, 1, 3, SDL_PIXELFORMAT_INDEX4LSB);
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp"); SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
@ -675,7 +675,7 @@ surface_testOverflow(void *arg)
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 7, 1, 4, 4, SDL_PIXELFORMAT_INDEX4LSB); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 7, 1, 4, SDL_PIXELFORMAT_INDEX4LSB);
SDLTest_AssertCheck(surface != NULL, "7px * 4 bits per px fits in 4 bytes: %s", SDLTest_AssertCheck(surface != NULL, "7px * 4 bits per px fits in 4 bytes: %s",
surface != NULL ? "(success)" : SDL_GetError()); surface != NULL ? "(success)" : SDL_GetError());
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
@ -685,7 +685,7 @@ surface_testOverflow(void *arg)
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
/* SDL_PIXELFORMAT_INDEX1* needs 1 byte per 8 pixels. */ /* SDL_PIXELFORMAT_INDEX1* needs 1 byte per 8 pixels. */
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 16, 1, 1, 2, SDL_PIXELFORMAT_INDEX1LSB); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 16, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
SDLTest_AssertCheck(surface != NULL, "16px * 1 bit per px fits in 2 bytes: %s", SDLTest_AssertCheck(surface != NULL, "16px * 1 bit per px fits in 2 bytes: %s",
surface != NULL ? "(success)" : SDL_GetError()); surface != NULL ? "(success)" : SDL_GetError());
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
@ -694,7 +694,7 @@ surface_testOverflow(void *arg)
surface != NULL ? "(success)" : SDL_GetError()); surface != NULL ? "(success)" : SDL_GetError());
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 17, 1, 1, 2, SDL_PIXELFORMAT_INDEX1LSB); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 17, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp"); SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
@ -703,7 +703,7 @@ surface_testOverflow(void *arg)
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 17, 1, 1, 3, SDL_PIXELFORMAT_INDEX1LSB); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 17, 1, 3, SDL_PIXELFORMAT_INDEX1LSB);
SDLTest_AssertCheck(surface != NULL, "17px * 1 bit per px fits in 3 bytes: %s", SDLTest_AssertCheck(surface != NULL, "17px * 1 bit per px fits in 3 bytes: %s",
surface != NULL ? "(success)" : SDL_GetError()); surface != NULL ? "(success)" : SDL_GetError());
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
@ -713,7 +713,7 @@ surface_testOverflow(void *arg)
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
/* SDL_PIXELFORMAT_INDEX8 and SDL_PIXELFORMAT_RGB332 require 1 byte per pixel. */ /* SDL_PIXELFORMAT_INDEX8 and SDL_PIXELFORMAT_RGB332 require 1 byte per pixel. */
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 5, 1, 8, 5, SDL_PIXELFORMAT_RGB332); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 5, 1, 5, SDL_PIXELFORMAT_RGB332);
SDLTest_AssertCheck(surface != NULL, "5px * 8 bits per px fits in 5 bytes: %s", SDLTest_AssertCheck(surface != NULL, "5px * 8 bits per px fits in 5 bytes: %s",
surface != NULL ? "(success)" : SDL_GetError()); surface != NULL ? "(success)" : SDL_GetError());
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
@ -722,7 +722,7 @@ surface_testOverflow(void *arg)
surface != NULL ? "(success)" : SDL_GetError()); surface != NULL ? "(success)" : SDL_GetError());
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 6, 1, 8, 5, SDL_PIXELFORMAT_RGB332); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 6, 1, 5, SDL_PIXELFORMAT_RGB332);
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp"); SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
@ -734,7 +734,7 @@ surface_testOverflow(void *arg)
/* Everything else requires more than 1 byte per pixel, and rounds up /* Everything else requires more than 1 byte per pixel, and rounds up
* each pixel to an integer number of bytes (e.g. RGB555 is really * each pixel to an integer number of bytes (e.g. RGB555 is really
* XRGB1555, with 1 bit per pixel wasted). */ * XRGB1555, with 1 bit per pixel wasted). */
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 3, 1, 15, 6, SDL_PIXELFORMAT_RGB555); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 3, 1, 6, SDL_PIXELFORMAT_RGB555);
SDLTest_AssertCheck(surface != NULL, "3px * 15 (really 16) bits per px fits in 6 bytes: %s", SDLTest_AssertCheck(surface != NULL, "3px * 15 (really 16) bits per px fits in 6 bytes: %s",
surface != NULL ? "(success)" : SDL_GetError()); surface != NULL ? "(success)" : SDL_GetError());
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
@ -743,7 +743,7 @@ surface_testOverflow(void *arg)
surface != NULL ? "(success)" : SDL_GetError()); surface != NULL ? "(success)" : SDL_GetError());
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 4, 1, 15, 6, SDL_PIXELFORMAT_RGB555); surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 4, 1, 6, SDL_PIXELFORMAT_RGB555);
SDLTest_AssertCheck(surface == NULL, "4px * 15 (really 16) bits per px doesn't fit in 6 bytes"); SDLTest_AssertCheck(surface == NULL, "4px * 15 (really 16) bits per px doesn't fit in 6 bytes");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
@ -754,19 +754,19 @@ surface_testOverflow(void *arg)
if (sizeof (size_t) == 4 && sizeof (int) >= 4) { if (sizeof (size_t) == 4 && sizeof (int) >= 4) {
expectedError = "Out of memory"; expectedError = "Out of memory";
surface = SDL_CreateRGBSurfaceWithFormat(0, SDL_MAX_SINT32, 1, 8, SDL_PIXELFORMAT_INDEX8); surface = SDL_CreateRGBSurfaceWithFormat(SDL_MAX_SINT32, 1, SDL_PIXELFORMAT_INDEX8);
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width + alignment"); SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width + alignment");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
surface = SDL_CreateRGBSurfaceWithFormat(0, SDL_MAX_SINT32 / 2, 1, 32, SDL_PIXELFORMAT_ARGB8888); surface = SDL_CreateRGBSurfaceWithFormat(SDL_MAX_SINT32 / 2, 1, SDL_PIXELFORMAT_ARGB8888);
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * bytes per pixel"); SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * bytes per pixel");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
surface = SDL_CreateRGBSurfaceWithFormat(0, (1 << 29) - 1, (1 << 29) - 1, 8, SDL_PIXELFORMAT_INDEX8); surface = SDL_CreateRGBSurfaceWithFormat((1 << 29) - 1, (1 << 29) - 1, SDL_PIXELFORMAT_INDEX8);
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * height"); SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * height");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
surface = SDL_CreateRGBSurfaceWithFormat(0, (1 << 15) + 1, (1 << 15) + 1, 32, SDL_PIXELFORMAT_ARGB8888); surface = SDL_CreateRGBSurfaceWithFormat((1 << 15) + 1, (1 << 15) + 1, SDL_PIXELFORMAT_ARGB8888);
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * height * bytes per pixel"); SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * height * bytes per pixel");
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());

View file

@ -612,7 +612,7 @@ main(int argc, char *argv[])
TTF_CloseFont(font); TTF_CloseFont(font);
TTF_Quit(); TTF_Quit();
#endif #endif
g_surf_sdf = SDL_ConvertSurfaceFormat(tmp, SDL_PIXELFORMAT_ABGR8888, 0); g_surf_sdf = SDL_ConvertSurfaceFormat(tmp, SDL_PIXELFORMAT_ABGR8888);
SDL_SetSurfaceBlendMode(g_surf_sdf, SDL_BLENDMODE_BLEND); SDL_SetSurfaceBlendMode(g_surf_sdf, SDL_BLENDMODE_BLEND);
} }

View file

@ -61,7 +61,7 @@ save_surface_to_bmp()
pixel_format = SDL_GetWindowPixelFormat(window); pixel_format = SDL_GetWindowPixelFormat(window);
SDL_PixelFormatEnumToMasks(pixel_format, &bbp, &r_mask, &g_mask, &b_mask, &a_mask); SDL_PixelFormatEnumToMasks(pixel_format, &bbp, &r_mask, &g_mask, &b_mask, &a_mask);
surface = SDL_CreateRGBSurface(0, width, height, bbp, r_mask, g_mask, b_mask, a_mask); surface = SDL_CreateRGBSurface(width, height, bbp, r_mask, g_mask, b_mask, a_mask);
SDL_RenderReadPixels(renderer, NULL, pixel_format, (void*)surface->pixels, surface->pitch); SDL_RenderReadPixels(renderer, NULL, pixel_format, (void*)surface->pixels, surface->pitch);
SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIs32 "-%8.8d.bmp", SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIs32 "-%8.8d.bmp",

View file

@ -324,7 +324,7 @@ SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord)
texcoord[2] = (GLfloat) surface->w / w; /* Max X */ texcoord[2] = (GLfloat) surface->w / w; /* Max X */
texcoord[3] = (GLfloat) surface->h / h; /* Max Y */ texcoord[3] = (GLfloat) surface->h / h; /* Max Y */
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, image = SDL_CreateRGBSurface(w, h, 32,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
0x000000FF, 0x000000FF,
0x0000FF00, 0x00FF0000, 0xFF000000 0x0000FF00, 0x00FF0000, 0xFF000000

View file

@ -27,7 +27,7 @@ static SDL_bool is_packed_yuv_format(Uint32 format)
/* Create a surface with a good pattern for verifying YUV conversion */ /* Create a surface with a good pattern for verifying YUV conversion */
static SDL_Surface *generate_test_pattern(int pattern_size) static SDL_Surface *generate_test_pattern(int pattern_size)
{ {
SDL_Surface *pattern = SDL_CreateRGBSurfaceWithFormat(0, pattern_size, pattern_size, 0, SDL_PIXELFORMAT_RGB24); SDL_Surface *pattern = SDL_CreateRGBSurfaceWithFormat(pattern_size, pattern_size, SDL_PIXELFORMAT_RGB24);
if (pattern) { if (pattern) {
int i, x, y; int i, x, y;
@ -325,7 +325,7 @@ main(int argc, char **argv)
} else { } else {
filename = "testyuv.bmp"; filename = "testyuv.bmp";
} }
original = SDL_ConvertSurfaceFormat(SDL_LoadBMP(filename), SDL_PIXELFORMAT_RGB24, 0); original = SDL_ConvertSurfaceFormat(SDL_LoadBMP(filename), SDL_PIXELFORMAT_RGB24);
if (original == NULL) { if (original == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
return 3; return 3;
@ -337,7 +337,7 @@ main(int argc, char **argv)
0, 100); 0, 100);
pitch = CalculateYUVPitch(yuv_format, original->w); pitch = CalculateYUVPitch(yuv_format, original->w);
converted = SDL_CreateRGBSurfaceWithFormat(0, original->w, original->h, 0, rgb_format); converted = SDL_CreateRGBSurfaceWithFormat(original->w, original->h, rgb_format);
if (converted == NULL) { if (converted == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create converted surface: %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create converted surface: %s\n", SDL_GetError());
return 3; return 3;