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:
Sam Lantinga 2024-07-08 14:59:18 -07:00
parent 40ed098ce8
commit 2ba76dbe80
123 changed files with 1865 additions and 1838 deletions

View file

@ -27,23 +27,23 @@
int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
{
if (!dst) {
if (!SDL_SurfaceValid(dst)) {
return SDL_InvalidParamError("SDL_DrawPoint(): dst");
}
/* This function doesn't work on surfaces < 8 bpp */
if (dst->format->bits_per_pixel < 8) {
if (dst->internal->format->bits_per_pixel < 8) {
return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
}
/* Perform clipping */
if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
x >= (dst->clip_rect.x + dst->clip_rect.w) ||
y >= (dst->clip_rect.y + dst->clip_rect.h)) {
if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y ||
x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) ||
y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) {
return 0;
}
switch (dst->format->bytes_per_pixel) {
switch (dst->internal->format->bytes_per_pixel) {
case 1:
DRAW_FASTSETPIXELXY1(x, y);
break;
@ -67,19 +67,19 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
int i;
int x, y;
if (!dst) {
if (!SDL_SurfaceValid(dst)) {
return SDL_InvalidParamError("SDL_DrawPoints(): dst");
}
/* This function doesn't work on surfaces < 8 bpp */
if (dst->format->bits_per_pixel < 8) {
if (dst->internal->format->bits_per_pixel < 8) {
return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
}
minx = dst->clip_rect.x;
maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
miny = dst->clip_rect.y;
maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
minx = dst->internal->clip_rect.x;
maxx = dst->internal->clip_rect.x + dst->internal->clip_rect.w - 1;
miny = dst->internal->clip_rect.y;
maxy = dst->internal->clip_rect.y + dst->internal->clip_rect.h - 1;
for (i = 0; i < count; ++i) {
x = points[i].x;
@ -89,7 +89,7 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
continue;
}
switch (dst->format->bytes_per_pixel) {
switch (dst->internal->format->bytes_per_pixel) {
case 1:
DRAW_FASTSETPIXELXY1(x, y);
break;