|
@@ -40,21 +40,9 @@ void _surfaceSetUp(void *arg)
|
|
|
int result;
|
|
|
SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
|
|
|
SDL_BlendMode currentBlendMode;
|
|
|
- Uint32 rmask, gmask, bmask, amask;
|
|
|
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
|
|
- rmask = 0xff000000;
|
|
|
- gmask = 0x00ff0000;
|
|
|
- bmask = 0x0000ff00;
|
|
|
- amask = 0x000000ff;
|
|
|
-#else
|
|
|
- rmask = 0x000000ff;
|
|
|
- gmask = 0x0000ff00;
|
|
|
- bmask = 0x00ff0000;
|
|
|
- amask = 0xff000000;
|
|
|
-#endif
|
|
|
-
|
|
|
+
|
|
|
referenceSurface = SDLTest_ImageBlit(); /* For size info */
|
|
|
- testSurface = SDL_CreateRGBSurface(referenceSurface->w, referenceSurface->h, 32, rmask, gmask, bmask, amask);
|
|
|
+ testSurface = SDL_CreateSurface(referenceSurface->w, referenceSurface->h, SDL_PIXELFORMAT_RGBA32);
|
|
|
SDLTest_AssertCheck(testSurface != NULL, "Check that testSurface is not NULL");
|
|
|
if (testSurface != NULL) {
|
|
|
/* Disable blend mode for target surface */
|
|
@@ -597,116 +585,116 @@ int surface_testOverflow(void *arg)
|
|
|
SDL_memset(buf, '\0', sizeof(buf));
|
|
|
|
|
|
expectedError = "Parameter 'width' is invalid";
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormat(-3, 100, SDL_PIXELFORMAT_INDEX8);
|
|
|
+ surface = SDL_CreateSurface(-3, 100, SDL_PIXELFORMAT_INDEX8);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect negative width");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, -1, 1, 4, SDL_PIXELFORMAT_INDEX8);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, -1, 1, 4, SDL_PIXELFORMAT_INDEX8);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect negative width");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, -1, 1, 32, 4, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, -1, 1, 4, SDL_PIXELFORMAT_RGBA8888);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect negative width");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
|
|
|
expectedError = "Parameter 'height' is invalid";
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormat(100, -3, SDL_PIXELFORMAT_INDEX8);
|
|
|
+ surface = SDL_CreateSurface(100, -3, SDL_PIXELFORMAT_INDEX8);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect negative height");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 1, -1, 4, SDL_PIXELFORMAT_INDEX8);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 1, -1, 4, SDL_PIXELFORMAT_INDEX8);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect negative height");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, 1, -1, 32, 4, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 1, -1, 4, SDL_PIXELFORMAT_RGBA8888);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect negative height");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
|
|
|
expectedError = "Parameter 'pitch' is invalid";
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 4, 1, -1, SDL_PIXELFORMAT_INDEX8);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 4, 1, -1, SDL_PIXELFORMAT_INDEX8);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect negative pitch");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, 1, 1, 32, -1, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 1, 1, -1, SDL_PIXELFORMAT_RGBA8888);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect negative pitch");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
|
|
|
/* 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
|
|
|
- * bits per pixel. SDL_PIXELFORMAT_INDEX4* needs 1 byte per 2 pixels. */
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 6, 1, 3, SDL_PIXELFORMAT_INDEX4LSB);
|
|
|
+ * bits per pixel. SDL_PIXELFORMAT_INDEX4LSB* needs 1 byte per 2 pixels. */
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 6, 1, 3, SDL_PIXELFORMAT_INDEX4LSB);
|
|
|
SDLTest_AssertCheck(surface != NULL, "6px * 4 bits per px fits in 3 bytes: %s",
|
|
|
surface != NULL ? "(success)" : SDL_GetError());
|
|
|
SDL_FreeSurface(surface);
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, 6, 1, 4, 3, 0, 0, 0, 0);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 6, 1, 3, SDL_PIXELFORMAT_INDEX4LSB);
|
|
|
SDLTest_AssertCheck(surface != NULL, "6px * 4 bits per px fits in 3 bytes: %s",
|
|
|
surface != NULL ? "(success)" : SDL_GetError());
|
|
|
SDL_FreeSurface(surface);
|
|
|
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 7, 1, 3, SDL_PIXELFORMAT_INDEX4LSB);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 7, 1, 3, SDL_PIXELFORMAT_INDEX4LSB);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, 7, 1, 4, 3, 0, 0, 0, 0);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 7, 1, 3, SDL_PIXELFORMAT_INDEX4LSB);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 7, 1, 4, SDL_PIXELFORMAT_INDEX4LSB);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 7, 1, 4, SDL_PIXELFORMAT_INDEX4LSB);
|
|
|
SDLTest_AssertCheck(surface != NULL, "7px * 4 bits per px fits in 4 bytes: %s",
|
|
|
surface != NULL ? "(success)" : SDL_GetError());
|
|
|
SDL_FreeSurface(surface);
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, 7, 1, 4, 4, 0, 0, 0, 0);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 7, 1, 4, SDL_PIXELFORMAT_INDEX4LSB);
|
|
|
SDLTest_AssertCheck(surface != NULL, "7px * 4 bits per px fits in 4 bytes: %s",
|
|
|
surface != NULL ? "(success)" : SDL_GetError());
|
|
|
SDL_FreeSurface(surface);
|
|
|
|
|
|
/* SDL_PIXELFORMAT_INDEX1* needs 1 byte per 8 pixels. */
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 16, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 16, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
|
|
|
SDLTest_AssertCheck(surface != NULL, "16px * 1 bit per px fits in 2 bytes: %s",
|
|
|
surface != NULL ? "(success)" : SDL_GetError());
|
|
|
SDL_FreeSurface(surface);
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, 16, 1, 1, 2, 0, 0, 0, 0);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 16, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
|
|
|
SDLTest_AssertCheck(surface != NULL, "16px * 1 bit per px fits in 2 bytes: %s",
|
|
|
surface != NULL ? "(success)" : SDL_GetError());
|
|
|
SDL_FreeSurface(surface);
|
|
|
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 17, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 17, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, 17, 1, 1, 2, 0, 0, 0, 0);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 17, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 17, 1, 3, SDL_PIXELFORMAT_INDEX1LSB);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 17, 1, 3, SDL_PIXELFORMAT_INDEX1LSB);
|
|
|
SDLTest_AssertCheck(surface != NULL, "17px * 1 bit per px fits in 3 bytes: %s",
|
|
|
surface != NULL ? "(success)" : SDL_GetError());
|
|
|
SDL_FreeSurface(surface);
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, 17, 1, 1, 3, 0, 0, 0, 0);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 17, 1, 3, SDL_PIXELFORMAT_INDEX1LSB);
|
|
|
SDLTest_AssertCheck(surface != NULL, "17px * 1 bit per px fits in 3 bytes: %s",
|
|
|
surface != NULL ? "(success)" : SDL_GetError());
|
|
|
SDL_FreeSurface(surface);
|
|
|
|
|
|
/* SDL_PIXELFORMAT_INDEX8 and SDL_PIXELFORMAT_RGB332 require 1 byte per pixel. */
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 5, 1, 5, SDL_PIXELFORMAT_RGB332);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 5, 1, 5, SDL_PIXELFORMAT_RGB332);
|
|
|
SDLTest_AssertCheck(surface != NULL, "5px * 8 bits per px fits in 5 bytes: %s",
|
|
|
surface != NULL ? "(success)" : SDL_GetError());
|
|
|
SDL_FreeSurface(surface);
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, 5, 1, 8, 5, 0, 0, 0, 0);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 5, 1, 5, SDL_PIXELFORMAT_INDEX8);
|
|
|
SDLTest_AssertCheck(surface != NULL, "5px * 8 bits per px fits in 5 bytes: %s",
|
|
|
surface != NULL ? "(success)" : SDL_GetError());
|
|
|
SDL_FreeSurface(surface);
|
|
|
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 6, 1, 5, SDL_PIXELFORMAT_RGB332);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 6, 1, 5, SDL_PIXELFORMAT_RGB332);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, 6, 1, 8, 5, 0, 0, 0, 0);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 6, 1, 5, SDL_PIXELFORMAT_INDEX8);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
@@ -714,39 +702,39 @@ int surface_testOverflow(void *arg)
|
|
|
/* 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
|
|
|
* XRGB1555, with 1 bit per pixel wasted). */
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 3, 1, 6, SDL_PIXELFORMAT_RGB555);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 3, 1, 6, SDL_PIXELFORMAT_RGB555);
|
|
|
SDLTest_AssertCheck(surface != NULL, "3px * 15 (really 16) bits per px fits in 6 bytes: %s",
|
|
|
surface != NULL ? "(success)" : SDL_GetError());
|
|
|
SDL_FreeSurface(surface);
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, 3, 1, 15, 6, 0, 0, 0, 0);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 3, 1, 6, SDL_PIXELFORMAT_RGB555);
|
|
|
SDLTest_AssertCheck(surface != NULL, "5px * 15 (really 16) bits per px fits in 6 bytes: %s",
|
|
|
surface != NULL ? "(success)" : SDL_GetError());
|
|
|
SDL_FreeSurface(surface);
|
|
|
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 4, 1, 6, SDL_PIXELFORMAT_RGB555);
|
|
|
+ surface = SDL_CreateSurfaceFrom(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(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
- surface = SDL_CreateRGBSurfaceFrom(buf, 4, 1, 15, 6, 0, 0, 0, 0);
|
|
|
+ surface = SDL_CreateSurfaceFrom(buf, 4, 1, 6, SDL_PIXELFORMAT_XRGB1555);
|
|
|
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,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
|
|
|
if (sizeof(size_t) == 4 && sizeof(int) >= 4) {
|
|
|
expectedError = "Out of memory";
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormat(SDL_MAX_SINT32, 1, SDL_PIXELFORMAT_INDEX8);
|
|
|
+ surface = SDL_CreateSurface(SDL_MAX_SINT32, 1, SDL_PIXELFORMAT_INDEX8);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width + alignment");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormat(SDL_MAX_SINT32 / 2, 1, SDL_PIXELFORMAT_ARGB8888);
|
|
|
+ surface = SDL_CreateSurface(SDL_MAX_SINT32 / 2, 1, SDL_PIXELFORMAT_ARGB8888);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * bytes per pixel");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormat((1 << 29) - 1, (1 << 29) - 1, SDL_PIXELFORMAT_INDEX8);
|
|
|
+ surface = SDL_CreateSurface((1 << 29) - 1, (1 << 29) - 1, SDL_PIXELFORMAT_INDEX8);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * height");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
|
|
- surface = SDL_CreateRGBSurfaceWithFormat((1 << 15) + 1, (1 << 15) + 1, SDL_PIXELFORMAT_ARGB8888);
|
|
|
+ surface = SDL_CreateSurface((1 << 15) + 1, (1 << 15) + 1, SDL_PIXELFORMAT_ARGB8888);
|
|
|
SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * height * bytes per pixel");
|
|
|
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
|
|
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|