diff --git a/VisualC-GDK/tests/testgdk/src/testgdk.cpp b/VisualC-GDK/tests/testgdk/src/testgdk.cpp index 1ac2033b3e..e3dff71f3a 100644 --- a/VisualC-GDK/tests/testgdk/src/testgdk.cpp +++ b/VisualC-GDK/tests/testgdk/src/testgdk.cpp @@ -188,7 +188,7 @@ static bool LoadSprite(const char *file) for (i = 0; i < state->num_windows; ++i) { /* This does the SDL_LoadBMP step repeatedly, but that's OK for test code. */ - sprites[i] = LoadTexture(state->renderers[i], file, true); + sprites[i] = LoadTexture(state->renderers[i], file); if (!sprites[i]) { return false; } diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 17539f2d52..4ac5ae3c22 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -1097,11 +1097,6 @@ static SDL_Surface *SDLTest_LoadIcon(const char *file) return NULL; } - if (icon->format == SDL_PIXELFORMAT_INDEX8) { - /* Set the colorkey */ - SDL_SetSurfaceColorKey(icon, 1, *((Uint8 *)icon->pixels)); - } - return icon; } diff --git a/test/icon.h b/test/icon.h index 8344617cf0..1fb435d044 100644 --- a/test/icon.h +++ b/test/icon.h @@ -2,18 +2,19 @@ unsigned char icon_png[] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02, 0x03, 0x00, 0x00, 0x00, 0x0e, 0x14, 0x92, 0x67, 0x00, 0x00, 0x00, - 0x09, 0x50, 0x4c, 0x54, 0x45, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x00, 0x53, 0xed, 0x60, 0xc2, 0x00, 0x00, 0x00, 0x69, 0x49, 0x44, - 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0xa0, 0x18, 0x84, 0x86, 0x42, 0x68, - 0xd6, 0x55, 0xab, 0x02, 0xc0, 0x0c, 0xa9, 0x55, 0xab, 0x96, 0x80, 0x19, - 0x59, 0xab, 0x56, 0xad, 0x04, 0xd1, 0x8c, 0xab, 0x80, 0xc0, 0x01, 0xc8, - 0x60, 0x03, 0x31, 0x26, 0x80, 0x18, 0x4b, 0xa3, 0x96, 0x46, 0x81, 0x18, - 0x52, 0x4b, 0x81, 0x70, 0x09, 0x98, 0x01, 0x14, 0x59, 0x02, 0xd1, 0x0d, - 0xd1, 0x8f, 0xc4, 0x58, 0x99, 0x85, 0xce, 0x80, 0x4a, 0x21, 0x0c, 0x9c, - 0xba, 0x6a, 0x55, 0x18, 0x88, 0xc1, 0xb8, 0x34, 0x34, 0x34, 0x0a, 0x64, - 0x17, 0x43, 0x66, 0x68, 0x68, 0x26, 0xc4, 0x3d, 0x53, 0xc3, 0x96, 0xa0, - 0xba, 0x10, 0xee, 0x66, 0x82, 0x00, 0x00, 0x0b, 0x4e, 0x32, 0x71, 0x69, - 0x34, 0x3a, 0xd6, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, - 0x42, 0x60, 0x82 + 0x0c, 0x50, 0x4c, 0x54, 0x45, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xff, 0x5a, 0x53, 0x1b, 0x29, 0x00, 0x00, 0x00, + 0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00, + 0x00, 0x6a, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0xa0, 0x18, + 0xac, 0x5a, 0x05, 0xa1, 0xb9, 0x42, 0x43, 0x17, 0x80, 0x19, 0xaa, 0xa1, + 0xa1, 0x11, 0x60, 0xc6, 0xd4, 0xd0, 0xd0, 0x30, 0x10, 0xcd, 0x14, 0x0a, + 0x04, 0x0d, 0x40, 0x06, 0x27, 0x88, 0x91, 0x00, 0x62, 0x44, 0x2d, 0x8d, + 0x5a, 0x0a, 0x62, 0xa8, 0x46, 0x3d, 0x8d, 0x7a, 0x1a, 0x01, 0x66, 0x00, + 0x45, 0x22, 0x20, 0xba, 0x21, 0xfa, 0x91, 0x18, 0x61, 0x53, 0xd1, 0x19, + 0x50, 0x29, 0x84, 0x81, 0x59, 0xa1, 0xa1, 0x2b, 0x41, 0x0c, 0xa6, 0xa8, + 0x55, 0xab, 0x96, 0x82, 0xec, 0x62, 0x98, 0xb6, 0x6a, 0xd5, 0x34, 0x88, + 0x7b, 0xb2, 0x56, 0x46, 0xa0, 0xba, 0x10, 0xee, 0x66, 0x82, 0x00, 0x00, + 0xe2, 0x90, 0x27, 0xdc, 0x70, 0xc2, 0x01, 0x8a, 0x00, 0x00, 0x00, 0x00, + 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; -unsigned int icon_png_len = 183; +unsigned int icon_png_len = 200; diff --git a/test/icon.png b/test/icon.png index 8bcb6e951a..ecd03cb4e5 100644 Binary files a/test/icon.png and b/test/icon.png differ diff --git a/test/icon2x.png b/test/icon2x.png index f62ef23e0d..8b166529ba 100644 Binary files a/test/icon2x.png and b/test/icon2x.png differ diff --git a/test/testaudio.c b/test/testaudio.c index 9d282babd0..5f2f443701 100644 --- a/test/testaudio.c +++ b/test/testaudio.c @@ -718,7 +718,7 @@ static Texture *CreateTexture(const char *fname) if (!tex) { SDL_Log("Out of memory!"); } else { - tex->texture = LoadTexture(state->renderers[0], fname, true); + tex->texture = LoadTexture(state->renderers[0], fname); if (!tex->texture) { SDL_Log("Failed to load '%s': %s", fname, SDL_GetError()); SDL_free(tex); diff --git a/test/testcustomcursor.c b/test/testcustomcursor.c index 4fb7ad5b87..6ac5306595 100644 --- a/test/testcustomcursor.c +++ b/test/testcustomcursor.c @@ -118,40 +118,9 @@ static const char *cross[] = { "16,16" }; -static SDL_Surface *load_image_file(const char *file) -{ - SDL_Surface *surface = SDL_LoadSurface(file); - if (surface) { - if (SDL_GetSurfacePalette(surface)) { - const Uint8 bpp = SDL_BITSPERPIXEL(surface->format); - const Uint8 mask = (1 << bpp) - 1; - if (SDL_PIXELORDER(surface->format) == SDL_BITMAPORDER_4321) - SDL_SetSurfaceColorKey(surface, 1, (*(Uint8 *)surface->pixels) & mask); - else - SDL_SetSurfaceColorKey(surface, 1, ((*(Uint8 *)surface->pixels) >> (8 - bpp)) & mask); - } else { - switch (SDL_BITSPERPIXEL(surface->format)) { - case 15: - SDL_SetSurfaceColorKey(surface, 1, (*(Uint16 *)surface->pixels) & 0x00007FFF); - break; - case 16: - SDL_SetSurfaceColorKey(surface, 1, *(Uint16 *)surface->pixels); - break; - case 24: - SDL_SetSurfaceColorKey(surface, 1, (*(Uint32 *)surface->pixels) & 0x00FFFFFF); - break; - case 32: - SDL_SetSurfaceColorKey(surface, 1, *(Uint32 *)surface->pixels); - break; - } - } - } - return surface; -} - static SDL_Surface *load_image(const char *file) { - SDL_Surface *surface = load_image_file(file); + SDL_Surface *surface = SDL_LoadSurface(file); if (surface) { /* Add a 2x version of this image, if available */ SDL_Surface *surface2x = NULL; @@ -166,7 +135,7 @@ static SDL_Surface *load_image(const char *file) } else { SDL_strlcat(file2x, "2x", len); } - surface2x = load_image_file(file2x); + surface2x = SDL_LoadSurface(file2x); SDL_free(file2x); } if (surface2x) { diff --git a/test/testffmpeg.c b/test/testffmpeg.c index 8ff1b93a49..da1420e14a 100644 --- a/test/testffmpeg.c +++ b/test/testffmpeg.c @@ -236,9 +236,6 @@ static SDL_Texture *CreateTexture(SDL_Renderer *r, unsigned char *data, unsigned if (src) { surface = SDL_LoadPNG_IO(src, true); if (surface) { - /* Treat white as transparent */ - SDL_SetSurfaceColorKey(surface, true, SDL_MapSurfaceRGB(surface, 255, 255, 255)); - texture = SDL_CreateTextureFromSurface(r, surface); *w = surface->w; *h = surface->h; diff --git a/test/testgeometry.c b/test/testgeometry.c index a45b35feaa..96586cd5e2 100644 --- a/test/testgeometry.c +++ b/test/testgeometry.c @@ -52,7 +52,7 @@ static int LoadSprite(const char *file) for (i = 0; i < state->num_windows; ++i) { /* This does the SDL_LoadPNG step repeatedly, but that's OK for test code. */ - sprites[i] = LoadTexture(state->renderers[i], file, true); + sprites[i] = LoadTexture(state->renderers[i], file); if (!sprites[i]) { return -1; } diff --git a/test/testgpu_spinning_cube.c b/test/testgpu_spinning_cube.c index 843d514001..c06e93afa5 100644 --- a/test/testgpu_spinning_cube.c +++ b/test/testgpu_spinning_cube.c @@ -126,9 +126,6 @@ static SDL_Texture *CreateSpriteTexture(SDL_Renderer *renderer, unsigned char *d if (src) { surface = SDL_LoadPNG_IO(src, true); if (surface) { - /* Treat white as transparent */ - SDL_SetSurfaceColorKey(surface, true, SDL_MapSurfaceRGB(surface, 255, 255, 255)); - texture = SDL_CreateTextureFromSurface(renderer, surface); SDL_DestroySurface(surface); } diff --git a/test/testgpurender_effects.c b/test/testgpurender_effects.c index a593890c47..acd90ba731 100644 --- a/test/testgpurender_effects.c +++ b/test/testgpurender_effects.c @@ -263,13 +263,13 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) return SDL_APP_FAILURE; } - background = LoadTexture(renderer, "sample.png", false); + background = LoadTexture(renderer, "sample.png"); if (!background) { SDL_Log("Couldn't create background: %s", SDL_GetError()); return SDL_APP_FAILURE; } - sprite = LoadTexture(renderer, "icon.png", true); + sprite = LoadTexture(renderer, "icon.png"); if (!sprite) { SDL_Log("Couldn't create sprite: %s", SDL_GetError()); return SDL_APP_FAILURE; diff --git a/test/testgpurender_msdf.c b/test/testgpurender_msdf.c index 32520744b0..2ba095a5d9 100644 --- a/test/testgpurender_msdf.c +++ b/test/testgpurender_msdf.c @@ -57,7 +57,7 @@ static GlyphInfo glyphs[128]; static bool LoadFontTexture(void) { - font_texture = LoadTexture(renderer, "msdf_font.png", false); + font_texture = LoadTexture(renderer, "msdf_font.png"); if (!font_texture) { SDL_Log("Failed to create font texture: %s", SDL_GetError()); return false; diff --git a/test/testime.c b/test/testime.c index 9005f17f50..d5ff7c91df 100644 --- a/test/testime.c +++ b/test/testime.c @@ -1018,7 +1018,7 @@ int main(int argc, char *argv[]) ctx->window = window; ctx->renderer = renderer; ctx->rendererID = i; - ctx->settings_icon = LoadTexture(renderer, "icon.png", true); + ctx->settings_icon = LoadTexture(renderer, "icon.png"); if (ctx->settings_icon) { ctx->settings_rect.w = (float)ctx->settings_icon->w; ctx->settings_rect.h = (float)ctx->settings_icon->h; diff --git a/test/testnative.c b/test/testnative.c index 5df1b66168..dcc648ecd2 100644 --- a/test/testnative.c +++ b/test/testnative.c @@ -168,7 +168,7 @@ int main(int argc, char *argv[]) SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(renderer); - sprite = LoadTexture(renderer, "icon.png", true); + sprite = LoadTexture(renderer, "icon.png"); if (!sprite) { quit(6); } diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index ce19fa12d9..c161470cb8 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -135,8 +135,8 @@ int main(int argc, char *argv[]) drawstate->window = state->windows[i]; drawstate->renderer = state->renderers[i]; - drawstate->sprite = LoadTexture(drawstate->renderer, "icon.png", true); - drawstate->background = LoadTexture(drawstate->renderer, "sample.png", false); + drawstate->sprite = LoadTexture(drawstate->renderer, "icon.png"); + drawstate->background = LoadTexture(drawstate->renderer, "sample.png"); if (!drawstate->sprite || !drawstate->background) { quit(2); } diff --git a/test/testrendertarget.c b/test/testrendertarget.c index 019b063885..08dad4df0f 100644 --- a/test/testrendertarget.c +++ b/test/testrendertarget.c @@ -252,8 +252,8 @@ int main(int argc, char *argv[]) drawstate->window = state->windows[i]; drawstate->renderer = state->renderers[i]; - drawstate->sprite = LoadTexture(drawstate->renderer, "icon.png", true); - drawstate->background = LoadTexture(drawstate->renderer, "sample.png", false); + drawstate->sprite = LoadTexture(drawstate->renderer, "icon.png"); + drawstate->background = LoadTexture(drawstate->renderer, "sample.png"); if (!drawstate->sprite || !drawstate->background) { quit(2); } diff --git a/test/testscale.c b/test/testscale.c index 08eee2e48d..caabeac507 100644 --- a/test/testscale.c +++ b/test/testscale.c @@ -153,8 +153,8 @@ int main(int argc, char *argv[]) drawstate->window = state->windows[i]; drawstate->renderer = state->renderers[i]; - drawstate->sprite = LoadTexture(drawstate->renderer, "icon.png", true); - drawstate->background = LoadTexture(drawstate->renderer, "sample.png", false); + drawstate->sprite = LoadTexture(drawstate->renderer, "icon.png"); + drawstate->background = LoadTexture(drawstate->renderer, "sample.png"); if (!drawstate->sprite || !drawstate->background) { quit(2); } diff --git a/test/testshape.c b/test/testshape.c index 610792d1ed..c8da41593e 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -91,14 +91,6 @@ int main(int argc, char *argv[]) goto quit; } - if (!SDL_ISPIXELFORMAT_ALPHA(shape->format)) { - /* Set the colorkey to the top-left pixel */ - Uint8 r, g, b, a; - - SDL_ReadSurfacePixel(shape, 0, 0, &r, &g, &b, &a); - SDL_SetSurfaceColorKey(shape, 1, SDL_MapSurfaceRGBA(shape, r, g, b, a)); - } - if (!resizable) { /* Set the hit test callback so we can drag the window */ if (!SDL_SetWindowHitTest(window, ShapeHitTest, shape)) { diff --git a/test/testsprite.c b/test/testsprite.c index 575be11630..6ce66fa60a 100644 --- a/test/testsprite.c +++ b/test/testsprite.c @@ -60,7 +60,7 @@ static bool LoadSprite(const char *file) if (sprites[i]) { SDL_DestroyTexture(sprites[i]); } - sprites[i] = LoadTexture(state->renderers[i], file, true); + sprites[i] = LoadTexture(state->renderers[i], file); if (sprites[i]) { sprite_w = (float)sprites[i]->w; sprite_h = (float)sprites[i]->h; diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c index 9d9bed336a..20860431d0 100644 --- a/test/testspriteminimal.c +++ b/test/testspriteminimal.c @@ -41,9 +41,6 @@ static SDL_Texture *CreateTexture(SDL_Renderer *r, unsigned char *data, unsigned if (src) { surface = SDL_LoadPNG_IO(src, true); if (surface) { - /* Treat white as transparent */ - SDL_SetSurfaceColorKey(surface, true, SDL_MapSurfaceRGB(surface, 255, 255, 255)); - texture = SDL_CreateTextureFromSurface(r, surface); *w = surface->w; *h = surface->h; diff --git a/test/testspritesurface.c b/test/testspritesurface.c index 69ff27dccb..71756042e8 100644 --- a/test/testspritesurface.c +++ b/test/testspritesurface.c @@ -40,9 +40,6 @@ static SDL_Surface *CreateSurface(unsigned char *data, unsigned int len, int *w, if (src) { surface = SDL_LoadPNG_IO(src, true); if (surface) { - /* Treat white as transparent */ - SDL_SetSurfaceColorKey(surface, true, SDL_MapSurfaceRGB(surface, 255, 255, 255)); - *w = surface->w; *h = surface->h; } diff --git a/test/testutils.c b/test/testutils.c index 79d5abfeca..c9139d4826 100644 --- a/test/testutils.c +++ b/test/testutils.c @@ -123,13 +123,11 @@ char *GetResourceFilename(const char *user_specified, const char *def) * Load the .png file whose name is file, from the SDL_GetBasePath() if * possible or the current working directory if not. * - * If transparent is true, set the transparent colour from the top left pixel. - * * If width_out is non-NULL, set it to the texture width. * * If height_out is non-NULL, set it to the texture height. */ -SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file, bool transparent) +SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file) { SDL_Surface *temp = NULL; SDL_Texture *texture = NULL; @@ -145,35 +143,6 @@ SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file, bool transpar if (!temp) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); } else { - /* Set transparent pixel as the pixel at (0,0) */ - if (transparent) { - if (SDL_GetSurfacePalette(temp)) { - const Uint8 bpp = SDL_BITSPERPIXEL(temp->format); - const Uint8 mask = (1 << bpp) - 1; - if (SDL_PIXELORDER(temp->format) == SDL_BITMAPORDER_4321) - SDL_SetSurfaceColorKey(temp, true, (*(Uint8 *)temp->pixels) & mask); - else - SDL_SetSurfaceColorKey(temp, true, ((*(Uint8 *)temp->pixels) >> (8 - bpp)) & mask); - } else { - switch (SDL_BITSPERPIXEL(temp->format)) { - case 15: - SDL_SetSurfaceColorKey(temp, true, - (*(Uint16 *)temp->pixels) & 0x00007FFF); - break; - case 16: - SDL_SetSurfaceColorKey(temp, true, *(Uint16 *)temp->pixels); - break; - case 24: - SDL_SetSurfaceColorKey(temp, true, - (*(Uint32 *)temp->pixels) & 0x00FFFFFF); - break; - case 32: - SDL_SetSurfaceColorKey(temp, true, *(Uint32 *)temp->pixels); - break; - } - } - } - texture = SDL_CreateTextureFromSurface(renderer, temp); if (!texture) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s", SDL_GetError()); diff --git a/test/testutils.h b/test/testutils.h index 83d7c295a3..e4da0a517b 100644 --- a/test/testutils.h +++ b/test/testutils.h @@ -20,7 +20,7 @@ extern "C" { #endif -extern SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file, bool transparent); +extern SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file); extern char *GetNearbyFilename(const char *file); extern char *GetResourceFilename(const char *user_specified, const char *def); diff --git a/test/testviewport.c b/test/testviewport.c index 0c05b8a47f..9b989af91e 100644 --- a/test/testviewport.c +++ b/test/testviewport.c @@ -183,7 +183,7 @@ int main(int argc, char *argv[]) quit(2); } - sprite = LoadTexture(state->renderers[0], "icon.png", true); + sprite = LoadTexture(state->renderers[0], "icon.png"); if (!sprite) { quit(2); } diff --git a/test/testwaylandcustom.c b/test/testwaylandcustom.c index 248204f3f0..138d1177f9 100644 --- a/test/testwaylandcustom.c +++ b/test/testwaylandcustom.c @@ -38,9 +38,6 @@ static SDL_Texture *CreateTexture(SDL_Renderer *r, unsigned char *data, unsigned if (src) { surface = SDL_LoadPNG_IO(src, true); if (surface) { - /* Treat white as transparent */ - SDL_SetSurfaceColorKey(surface, true, SDL_MapSurfaceRGB(surface, 255, 255, 255)); - texture = SDL_CreateTextureFromSurface(r, surface); *w = surface->w; *h = surface->h;