Skip to content

Commit

Permalink
Raise minimum supported SDL2 to 2.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
ankith26 committed Nov 3, 2024
1 parent de88561 commit 03bfa77
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 124 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Dependency versions:
+----------+------------------------+
| CPython | >= 3.8 (Or use PyPy3) |
+----------+------------------------+
| SDL | >= 2.0.10 |
| SDL | >= 2.0.14 |
+----------+------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+------------------------+
Expand Down
5 changes: 1 addition & 4 deletions docs/reST/ref/system.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@
'LASX': False
}

.. Note:: The value of ``ARMSIMD`` will be always False if
SDL version < 2.0.12.

The values of ``LSX`` and ``LASX`` will be always False if
.. Note:: The values of ``LSX`` and ``LASX`` will be always False if
SDL version < 2.24.0.

.. versionadded:: 2.3.1
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.10 |
| SDL | >= 2.0.14 |
+----------+-----------------------------+
| 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.10 |
| SDL | >= 2.0.14 |
+----------+------------------------+
| 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.10 |
| SDL | >= 2.0.14 |
+----------+-----------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+-----------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readmes/README.it.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Le versioni dei requisiti:
+----------+------------------------+
| CPython | >= 3.8 (Or use PyPy3) |
+----------+------------------------+
| SDL | >= 2.0.10 |
| SDL | >= 2.0.14 |
+----------+------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readmes/README.ja.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ gfxdraw には SDL_gfx の埋め込みバージョンが含まれています。
+----------+------------------------+
| CPython | >= 3.8 (Or use PyPy3) |
+----------+------------------------+
| SDL | >= 2.0.10 |
| SDL | >= 2.0.14 |
+----------+------------------------+
| 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 @@ -106,7 +106,7 @@ pygame显然依赖于SDL和Python。此外pygame还嵌入了几个较小的库
+----------+------------------------+
| CPython | >= 3.8 (或 PyPy3) |
+----------+------------------------+
| SDL | >= 2.0.10 |
| SDL | >= 2.0.14 |
+----------+------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+------------------------+
Expand Down
2 changes: 1 addition & 1 deletion src_c/_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ camera_get_image(pgCameraObject *self, PyObject *arg)
return NULL;

if (!surfobj) {
surf = PG_CreateSurface(width, height, PG_PIXELFORMAT_XRGB8888);
surf = PG_CreateSurface(width, height, SDL_PIXELFORMAT_XRGB8888);
}
else {
surf = pgSurface_AsSurface(surfobj);
Expand Down
40 changes: 0 additions & 40 deletions src_c/_pygame.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,47 +188,7 @@ PG_UnlockMutex(SDL_mutex *mutex)

#define PG_INIT_TIMER SDL_INIT_TIMER

#if SDL_VERSION_ATLEAST(2, 0, 14)
#define PG_SurfaceHasRLE SDL_HasSurfaceRLE
#else
// vendored in until our lowest SDL version is 2.0.14
typedef struct {
Uint8 *src;
int src_w, src_h;
int src_pitch;
int src_skip;
Uint8 *dst;
int dst_w, dst_h;
int dst_pitch;
int dst_skip;
SDL_PixelFormat *src_fmt;
SDL_PixelFormat *dst_fmt;
Uint8 *table;
int flags;
Uint32 colorkey;
Uint8 r, g, b, a;
} SDL_InternalBlitInfo;

struct SDL_BlitMap {
SDL_Surface *dst;
int identity;
SDL_blit blit;
void *data;
SDL_InternalBlitInfo info;

/* the version count matches the destination; mismatch indicates
an invalid mapping */
Uint32 dst_palette_version;
Uint32 src_palette_version;
};
#define SDL_COPY_RLE_DESIRED 0x00001000

#define PG_SurfaceHasRLE(surface) \
(((surface) == NULL) \
? 0 \
: ((surface)->map->info.flags & SDL_COPY_RLE_DESIRED))

#endif

#endif

Expand Down
6 changes: 0 additions & 6 deletions src_c/_sdl2/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ controller_rumble(pgControllerObject *self, PyObject *args, PyObject *kwargs)
return RAISE(pgExc_SDLError, "Controller is not initalized");
}

#if SDL_VERSION_ATLEAST(2, 0, 9)
// rumble takes values in range 0 to 0xFFFF (65535)
low_freq = MAX(MIN(low_freq, 1.0f), 0.0f) * 65535;
high_freq = MAX(MIN(high_freq, 1.0f), 0.0f) * 65535;
Expand All @@ -376,9 +375,6 @@ controller_rumble(pgControllerObject *self, PyObject *args, PyObject *kwargs)
(Uint16)high_freq, duration);

return PyBool_FromLong(success == 0);
#else
Py_RETURN_FALSE;
#endif
}

static PyObject *
Expand All @@ -388,9 +384,7 @@ controller_stop_rumble(pgControllerObject *self, PyObject *_null)
if (!self->controller) {
return RAISE(pgExc_SDLError, "Controller is not initalized");
}
#if SDL_VERSION_ATLEAST(2, 0, 9)
SDL_GameControllerRumble(self->controller, 0, 0, 1);
#endif
Py_RETURN_NONE;
}

Expand Down
8 changes: 0 additions & 8 deletions src_c/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,11 @@ MODINIT_DEFINE(constants)
DEC_CONST(CONTROLLERDEVICEADDED);
DEC_CONST(CONTROLLERDEVICEREMOVED);
DEC_CONST(CONTROLLERDEVICEREMAPPED);
#if SDL_VERSION_ATLEAST(2, 0, 14)
DEC_CONST(CONTROLLERTOUCHPADDOWN);
DEC_CONST(CONTROLLERTOUCHPADMOTION);
DEC_CONST(CONTROLLERTOUCHPADUP);
DEC_CONST(CONTROLLERSENSORUPDATE);
DEC_CONST(LOCALECHANGED);
#else
DEC_CONSTS(CONTROLLERTOUCHPADDOWN, -1);
DEC_CONSTS(CONTROLLERTOUCHPADMOTION, -1);
DEC_CONSTS(CONTROLLERTOUCHPADUP, -1);
DEC_CONSTS(CONTROLLERSENSORUPDATE, -1);
DEC_CONSTS(LOCALECHANGED, -1);
#endif

DEC_CONST(JOYDEVICEADDED);
DEC_CONST(JOYDEVICEREMOVED);
Expand Down
19 changes: 4 additions & 15 deletions src_c/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ pg_ResizeEventWatch(void *userdata, SDL_Event *event)
int h = event->window.data2;
pgSurfaceObject *display_surface = pg_GetDefaultWindowSurface();
SDL_Surface *surf =
PG_CreateSurface(w, h, PG_PIXELFORMAT_XRGB8888);
PG_CreateSurface(w, h, SDL_PIXELFORMAT_XRGB8888);

SDL_FreeSurface(display_surface->surf);
display_surface->surf = surf;
Expand Down Expand Up @@ -1156,7 +1156,7 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
So we make a fake surface.
*/
surf = PG_CreateSurface(w, h, PG_PIXELFORMAT_XRGB8888);
surf = PG_CreateSurface(w, h, SDL_PIXELFORMAT_XRGB8888);
newownedsurf = surf;
}
else {
Expand Down Expand Up @@ -1265,7 +1265,7 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
pg_renderer, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, w, h);
}
surf = PG_CreateSurface(w, h, PG_PIXELFORMAT_XRGB8888);
surf = PG_CreateSurface(w, h, SDL_PIXELFORMAT_XRGB8888);
newownedsurf = surf;
}
else {
Expand Down Expand Up @@ -1571,7 +1571,7 @@ pg_list_modes(PyObject *self, PyObject *args, PyObject *kwds)
}
/* use reasonable defaults (cf. SDL_video.c) */
if (!mode.format)
mode.format = PG_PIXELFORMAT_XRGB8888;
mode.format = SDL_PIXELFORMAT_XRGB8888;
if (!mode.w)
mode.w = 640;
if (!mode.h)
Expand Down Expand Up @@ -2803,9 +2803,7 @@ pg_message_box(PyObject *self, PyObject *arg, PyObject *kwargs)
return NULL;
}

#if SDL_VERSION_ATLEAST(2, 0, 12)
msgbox_data.flags |= SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT;
#endif

if (parent_window == Py_None) {
msgbox_data.window = NULL;
Expand Down Expand Up @@ -2896,12 +2894,7 @@ pg_message_box(PyObject *self, PyObject *arg, PyObject *kwargs)

buttons_data = malloc(sizeof(SDL_MessageBoxButtonData) * num_buttons);
for (Py_ssize_t i = 0; i < num_buttons; i++) {
#if SDL_VERSION_ATLEAST(2, 0, 12)
PyObject *btn_name_obj = PySequence_GetItem(buttons, i);
#else
PyObject *btn_name_obj =
PySequence_GetItem(buttons, num_buttons - i - 1);
#endif
if (!btn_name_obj)
goto error;

Expand All @@ -2916,11 +2909,7 @@ pg_message_box(PyObject *self, PyObject *arg, PyObject *kwargs)
goto error;

buttons_data[i].text = btn_name;
#if SDL_VERSION_ATLEAST(2, 0, 12)
buttons_data[i].buttonid = (int)i;
#else
buttons_data[i].buttonid = (int)(num_buttons - i - 1);
#endif
buttons_data[i].flags = 0;
if (return_button_index == buttons_data[i].buttonid)
buttons_data[i].flags |=
Expand Down
12 changes: 0 additions & 12 deletions src_c/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,10 @@ _pg_pgevent_proxify_helper(Uint32 type, Uint8 proxify)
_PG_HANDLE_PROXIFY(CONTROLLERDEVICEADDED);
_PG_HANDLE_PROXIFY(CONTROLLERDEVICEREMOVED);
_PG_HANDLE_PROXIFY(CONTROLLERDEVICEREMAPPED);
#if SDL_VERSION_ATLEAST(2, 0, 14)
_PG_HANDLE_PROXIFY(CONTROLLERTOUCHPADDOWN);
_PG_HANDLE_PROXIFY(CONTROLLERTOUCHPADMOTION);
_PG_HANDLE_PROXIFY(CONTROLLERTOUCHPADUP);
_PG_HANDLE_PROXIFY(CONTROLLERSENSORUPDATE);
#endif
_PG_HANDLE_PROXIFY(DOLLARGESTURE);
_PG_HANDLE_PROXIFY(DOLLARRECORD);
_PG_HANDLE_PROXIFY(DROPFILE);
Expand All @@ -367,9 +365,7 @@ _pg_pgevent_proxify_helper(Uint32 type, Uint8 proxify)
_PG_HANDLE_PROXIFY(JOYBUTTONUP);
_PG_HANDLE_PROXIFY(JOYDEVICEADDED);
_PG_HANDLE_PROXIFY(JOYDEVICEREMOVED);
#if SDL_VERSION_ATLEAST(2, 0, 14)
_PG_HANDLE_PROXIFY(LOCALECHANGED);
#endif
_PG_HANDLE_PROXIFY(MOUSEMOTION);
_PG_HANDLE_PROXIFY(MOUSEBUTTONDOWN);
_PG_HANDLE_PROXIFY(MOUSEBUTTONUP);
Expand Down Expand Up @@ -756,10 +752,8 @@ _pg_name_from_eventtype(int type)
return "KeyUp";
case SDL_KEYMAPCHANGED:
return "KeyMapChanged";
#if SDL_VERSION_ATLEAST(2, 0, 14)
case SDL_LOCALECHANGED:
return "LocaleChanged";
#endif
case SDL_MOUSEMOTION:
return "MouseMotion";
case SDL_MOUSEBUTTONDOWN:
Expand Down Expand Up @@ -828,7 +822,6 @@ _pg_name_from_eventtype(int type)
return "JoyDeviceAdded";
case SDL_JOYDEVICEREMOVED:
return "JoyDeviceRemoved";
#if SDL_VERSION_ATLEAST(2, 0, 14)
case SDL_CONTROLLERTOUCHPADDOWN:
return "ControllerTouchpadDown";
case SDL_CONTROLLERTOUCHPADMOTION:
Expand All @@ -837,7 +830,6 @@ _pg_name_from_eventtype(int type)
return "ControllerTouchpadUp";
case SDL_CONTROLLERSENSORUPDATE:
return "ControllerSensorUpdate";
#endif /*SDL_VERSION_ATLEAST(2, 0, 14)*/
case SDL_AUDIODEVICEADDED:
return "AudioDeviceAdded";
case SDL_AUDIODEVICEREMOVED:
Expand Down Expand Up @@ -1215,7 +1207,6 @@ dict_from_event(SDL_Event *event)
_pg_insobj(dict, "instance_id",
PyLong_FromLong(event->jdevice.which));
break;
#if SDL_VERSION_ATLEAST(2, 0, 14)
case SDL_CONTROLLERTOUCHPADDOWN:
case SDL_CONTROLLERTOUCHPADMOTION:
case SDL_CONTROLLERTOUCHPADUP:
Expand All @@ -1230,7 +1221,6 @@ dict_from_event(SDL_Event *event)
_pg_insobj(dict, "pressure",
PyFloat_FromDouble(event->ctouchpad.pressure));
break;
#endif /*SDL_VERSION_ATLEAST(2, 0, 14)*/

#ifdef WIN32
case SDL_SYSWMEVENT:
Expand Down Expand Up @@ -1318,14 +1308,12 @@ dict_from_event(SDL_Event *event)
window = SDL_GetWindowFromID(event->button.windowID);
break;
}
#if SDL_VERSION_ATLEAST(2, 0, 14)
case SDL_FINGERMOTION:
case SDL_FINGERDOWN:
case SDL_FINGERUP: {
window = SDL_GetWindowFromID(event->tfinger.windowID);
break;
}
#endif
default: {
return dict;
}
Expand Down
2 changes: 1 addition & 1 deletion src_c/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ font_render(PyObject *self, PyObject *args, PyObject *kwds)

if (strlen(astring) == 0) { /* special 0 string case */
int height = TTF_FontHeight(font);
surf = PG_CreateSurface(0, height, PG_PIXELFORMAT_XRGB8888);
surf = PG_CreateSurface(0, height, SDL_PIXELFORMAT_XRGB8888);
}
else { /* normal case */
if (antialias && bg_rgba_obj == Py_None) {
Expand Down
18 changes: 1 addition & 17 deletions src_c/include/pgcompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,13 @@ typedef uint8_t Uint8;
* warning without this check here, which is very weird. */
#ifdef SDL_VERSION_ATLEAST

// SDL_PIXELFORMAT_XRGB8888 and SDL_PIXELFORMAT_XBGR8888 are new names
// in SDL 2.0.14, the macros below let us use the new (less confusing)
// naming while still building on old versions.

#if SDL_VERSION_ATLEAST(2, 0, 14)
#define PG_PIXELFORMAT_XRGB8888 SDL_PIXELFORMAT_XRGB8888
#else
#define PG_PIXELFORMAT_XRGB8888 SDL_PIXELFORMAT_RGB888
#endif

#if SDL_VERSION_ATLEAST(2, 0, 14)
#define PG_PIXELFORMAT_XBGR8888 SDL_PIXELFORMAT_XBGR8888
#else
#define PG_PIXELFORMAT_XBGR8888 SDL_PIXELFORMAT_BGR888
#endif

// SDL does not provide endian independent names for 32 bit formats without
// alpha channels the way they do for ones with alpha channels.
// E.g. SDL_PIXELFORMAT_RGBA32. This macro allows us the convenience of the
// endian independent name.

#if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define PG_PIXELFORMAT_RGBX32 PG_PIXELFORMAT_XBGR8888
#define PG_PIXELFORMAT_RGBX32 SDL_PIXELFORMAT_XBGR8888
#else
#define PG_PIXELFORMAT_RGBX32 SDL_PIXELFORMAT_RGBX8888
#endif
Expand Down
2 changes: 1 addition & 1 deletion src_c/pixelcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ make_surface(PyObject *self, PyObject *arg)
pixelformat = SDL_PIXELFORMAT_INDEX8;
}
else {
pixelformat = PG_PIXELFORMAT_XRGB8888;
pixelformat = SDL_PIXELFORMAT_XRGB8888;
}
sizex = (int)view_p->shape[0];
sizey = (int)view_p->shape[1];
Expand Down
2 changes: 1 addition & 1 deletion src_c/simd_transform_sse2.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ filter_shrink_Y_SSE2(Uint8 *srcpix, Uint8 *dstpix, int width, int srcpitch,

Uint16 *templine;
/* allocate a clear memory area for storing the accumulator line */
// Future: when we support SDL 2.0.10 and up, we can use SDL_SIMDAlloc
// Future: when we support SDL 2.0.14 and up, we can use SDL_SIMDAlloc
// here so accumulate load/stores can be aligned, for a small perf
// improvement.
templine = (Uint16 *)calloc(dstpitch, 2);
Expand Down
2 changes: 1 addition & 1 deletion src_c/surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ pg_DisplayFormatAlpha(SDL_Surface *surface)
#endif
case SDL_PIXELFORMAT_ABGR1555:
case SDL_PIXELFORMAT_BGR565:
case PG_PIXELFORMAT_XBGR8888:
case SDL_PIXELFORMAT_XBGR8888:
case SDL_PIXELFORMAT_ABGR8888:
pfe = SDL_PIXELFORMAT_ABGR8888;
break;
Expand Down
Loading

0 comments on commit 03bfa77

Please sign in to comment.