mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-13 23:34:16 +02:00
Simplified SDL_Surface
SDL_Surface has been simplified and internal details are no longer in the public structure. The `format` member of SDL_Surface is now an enumerated pixel format value. You can get the full details of the pixel format by calling `SDL_GetPixelFormatDetails(surface->format)`. You can get the palette associated with the surface by calling SDL_GetSurfacePalette(). You can get the clip rectangle by calling SDL_GetSurfaceClipRect(). SDL_PixelFormat has been renamed SDL_PixelFormatDetails and just describes the pixel format, it does not include a palette for indexed pixel types. SDL_PixelFormatEnum has been renamed SDL_PixelFormat and is used instead of Uint32 for API functions that refer to pixel format by enumerated value. SDL_MapRGB(), SDL_MapRGBA(), SDL_GetRGB(), and SDL_GetRGBA() take an optional palette parameter for indexed color lookups.
This commit is contained in:
@@ -1038,14 +1038,14 @@ static void SDLTest_PrintRenderer(SDL_Renderer *renderer)
|
||||
int i;
|
||||
char text[1024];
|
||||
int max_texture_size;
|
||||
const SDL_PixelFormatEnum *texture_formats;
|
||||
const SDL_PixelFormat *texture_formats;
|
||||
|
||||
name = SDL_GetRendererName(renderer);
|
||||
|
||||
SDL_Log(" Renderer %s:\n", name);
|
||||
SDL_Log(" VSync: %d\n", (int)SDL_GetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_VSYNC_NUMBER, 0));
|
||||
|
||||
texture_formats = (const SDL_PixelFormatEnum *)SDL_GetProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER, NULL);
|
||||
texture_formats = (const SDL_PixelFormat *)SDL_GetProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER, NULL);
|
||||
if (texture_formats) {
|
||||
(void)SDL_snprintf(text, sizeof(text), " Texture formats: ");
|
||||
for (i = 0; texture_formats[i]; ++i) {
|
||||
@@ -1074,7 +1074,7 @@ static SDL_Surface *SDLTest_LoadIcon(const char *file)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (icon->format->palette) {
|
||||
if (icon->format == SDL_PIXELFORMAT_INDEX8) {
|
||||
/* Set the colorkey */
|
||||
SDL_SetSurfaceColorKey(icon, 1, *((Uint8 *)icon->pixels));
|
||||
}
|
||||
@@ -1218,7 +1218,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
|
||||
SDL_Log("Usable bounds: %dx%d at %d,%d\n", usablebounds.w, usablebounds.h, usablebounds.x, usablebounds.y);
|
||||
|
||||
mode = SDL_GetDesktopDisplayMode(displayID);
|
||||
SDL_GetMasksForPixelFormatEnum(mode->format, &bpp, &Rmask, &Gmask,
|
||||
SDL_GetMasksForPixelFormat(mode->format, &bpp, &Rmask, &Gmask,
|
||||
&Bmask, &Amask);
|
||||
SDL_Log(" Desktop mode: %dx%d@%gx %gHz, %d bits-per-pixel (%s)\n",
|
||||
mode->w, mode->h, mode->pixel_density, mode->refresh_rate, bpp,
|
||||
@@ -1240,7 +1240,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
|
||||
SDL_Log(" Fullscreen video modes:\n");
|
||||
for (j = 0; j < m; ++j) {
|
||||
mode = modes[j];
|
||||
SDL_GetMasksForPixelFormatEnum(mode->format, &bpp, &Rmask,
|
||||
SDL_GetMasksForPixelFormat(mode->format, &bpp, &Rmask,
|
||||
&Gmask, &Bmask, &Amask);
|
||||
SDL_Log(" Mode %d: %dx%d@%gx %gHz, %d bits-per-pixel (%s)\n",
|
||||
j, mode->w, mode->h, mode->pixel_density, mode->refresh_rate, bpp,
|
||||
|
||||
@@ -33,17 +33,6 @@
|
||||
/* Counter for _CompareSurface calls; used for filename creation when comparisons fail */
|
||||
static int _CompareSurfaceCount = 0;
|
||||
|
||||
static void
|
||||
LogErrorFormat(const char *name, const SDL_PixelFormat *format)
|
||||
{
|
||||
SDLTest_LogError("%s: %08d %s, %u bits/%u bytes per pixel", name, format->format, SDL_GetPixelFormatName(format->format),
|
||||
format->bits_per_pixel, format->bytes_per_pixel);
|
||||
SDLTest_LogError("%s: R mask %08" SDL_PRIx32 ", loss %u, shift %u", name, format->Rmask, format->Rloss, format->Rshift);
|
||||
SDLTest_LogError("%s: G mask %08" SDL_PRIx32 ", loss %u, shift %u", name, format->Gmask, format->Gloss, format->Gshift);
|
||||
SDLTest_LogError("%s: B mask %08" SDL_PRIx32 ", loss %u, shift %u", name, format->Bmask, format->Bloss, format->Bshift);
|
||||
SDLTest_LogError("%s: A mask %08" SDL_PRIx32 ", loss %u, shift %u", name, format->Amask, format->Aloss, format->Ashift);
|
||||
}
|
||||
|
||||
/* Compare surfaces */
|
||||
int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error)
|
||||
{
|
||||
@@ -135,8 +124,8 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface,
|
||||
_CompareSurfaceCount++;
|
||||
if (ret != 0) {
|
||||
SDLTest_LogError("Comparison of pixels with allowable error of %i failed %i times.", allowable_error, ret);
|
||||
LogErrorFormat("Reference surface format", referenceSurface->format);
|
||||
LogErrorFormat("Actual surface format ", surface->format);
|
||||
SDLTest_LogError("Reference surface format: %s", SDL_GetPixelFormatName(referenceSurface->format));
|
||||
SDLTest_LogError("Actual surface format: %s", SDL_GetPixelFormatName(surface->format));
|
||||
SDLTest_LogError("First detected occurrence at position %i,%i with a squared RGB-difference of %i.", sampleErrorX, sampleErrorY, sampleDist);
|
||||
SDLTest_LogError("Reference pixel: R=%u G=%u B=%u A=%u", sampleReference.r, sampleReference.g, sampleReference.b, sampleReference.a);
|
||||
SDLTest_LogError("Actual pixel : R=%u G=%u B=%u A=%u", sampleActual.r, sampleActual.g, sampleActual.b, sampleActual.a);
|
||||
|
||||
Reference in New Issue
Block a user