Skip to content

Commit

Permalink
Raise minimum SDL version to 2.0.10
Browse files Browse the repository at this point in the history
We recently raised our minimum Python to 3.8, In Linux-land, this corresponds to Ubuntu focal, which packages SDL2 2.0.10. Therefore it is reasonable to raise our minimum version to 2.0.10.
  • Loading branch information
Starbuck5 committed Nov 22, 2023
1 parent 2867369 commit 56fe66e
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 53 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Dependency versions:
+----------+------------------------+
| CPython | >= 3.8 (Or use PyPy3) |
+----------+------------------------+
| SDL | >= 2.0.9 |
| SDL | >= 2.0.10 |
+----------+------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readmes/README.es.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Versiones de dependencia:
+----------+-----------------------------+
| CPython | >= 3.8 (Ou utiliser PyPy3) |
+----------+-----------------------------+
| SDL | >= 2.0.9 |
| SDL | >= 2.0.10 |
+----------+-----------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+-----------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readmes/README.fa.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ Dependencies (وابستگی ها)
+----------+------------------------+
| CPython | >= 3.8 (Or use PyPy3) |
+----------+------------------------+
| SDL | >= 2.0.9 |
| SDL | >= 2.0.10 |
+----------+------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readmes/README.fr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Versions des dépendances:
+----------+-----------------------------+
| CPython | >= 3.8 (Ou utiliser PyPy3) |
+----------+-----------------------------+
| SDL | >= 2.0.9 |
| SDL | >= 2.0.10 |
+----------+-----------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+-----------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readmes/README.zh-cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pygame显然依赖于SDL和Python。此外pygame还嵌入了几个较小的库
+----------+------------------------+
| CPython | >= 3.8 (或 PyPy3) |
+----------+------------------------+
| SDL | >= 2.0.9 |
| SDL | >= 2.0.10 |
+----------+------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+------------------------+
Expand Down
13 changes: 0 additions & 13 deletions src_c/pgcompat_rect.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@

#include <SDL.h>

#if !(SDL_VERSION_ATLEAST(2, 0, 10))
typedef struct SDL_FRect {
float x, y;
float w, h;
} SDL_FRect;

typedef struct SDL_FPoint {
float x;
float y;
} SDL_FPoint;

#endif /* !(SDL_VERSION_ATLEAST(2, 0, 10)) */

/* SDL 2.0.22 provides some utility functions for FRects */
#if !(SDL_VERSION_ATLEAST(2, 0, 22))

Expand Down
37 changes: 2 additions & 35 deletions src_c/surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,39 +263,6 @@ pg_DisplayFormat(SDL_Surface *surface);
static int
_PgSurface_SrcAlpha(SDL_Surface *surf);

#if !SDL_VERSION_ATLEAST(2, 0, 10)
static Uint32
pg_map_rgb(SDL_Surface *surf, Uint8 r, Uint8 g, Uint8 b)
{
/* SDL_MapRGB() returns wrong values for color keys
for indexed formats since since alpha = 0 */
Uint32 key;
if (!surf->format->palette)
return SDL_MapRGB(surf->format, r, g, b);
if (!SDL_GetColorKey(surf, &key)) {
Uint8 keyr, keyg, keyb;
SDL_GetRGB(key, surf->format, &keyr, &keyg, &keyb);
if (r == keyr && g == keyg && b == keyb)
return key;
}
else
SDL_ClearError();
return SDL_MapRGBA(surf->format, r, g, b, SDL_ALPHA_OPAQUE);
}

static Uint32
pg_map_rgba(SDL_Surface *surf, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
if (!surf->format->palette)
return SDL_MapRGBA(surf->format, r, g, b, a);
return pg_map_rgb(surf, r, g, b);
}
#else /* SDL_VERSION_ATLEAST(2, 0, 10) */
#define pg_map_rgb(surf, r, g, b) SDL_MapRGB((surf)->format, (r), (g), (b))
#define pg_map_rgba(surf, r, g, b, a) \
SDL_MapRGBA((surf)->format, (r), (g), (b), (a))
#endif /* SDL_VERSION_ATLEAST(2, 0, 10) */

static PyGetSetDef surface_getsets[] = {
{"_pixels_address", (getter)surf_get_pixels_address, NULL,
"pixel buffer address (readonly)", NULL},
Expand Down Expand Up @@ -976,7 +943,7 @@ surf_map_rgb(PyObject *self, PyObject *args)

SURF_INIT_CHECK(surf)

color = pg_map_rgba(surf, rgba[0], rgba[1], rgba[2], rgba[3]);
color = SDL_MapRGBA(surf->format, rgba[0], rgba[1], rgba[2], rgba[3]);
return PyLong_FromLong(color);
}

Expand Down Expand Up @@ -1604,7 +1571,7 @@ surf_convert(pgSurfaceObject *self, PyObject *args)
}

if (has_colorkey) {
colorkey = pg_map_rgba(newsurf, key_r, key_g, key_b, key_a);
colorkey = SDL_MapRGBA(newsurf->format, key_r, key_g, key_b, key_a);
if (SDL_SetColorKey(newsurf, SDL_TRUE, colorkey) != 0) {
PyErr_SetString(pgExc_SDLError, SDL_GetError());
SDL_FreeSurface(newsurf);
Expand Down

0 comments on commit 56fe66e

Please sign in to comment.