diff --git a/src_c/image.c b/src_c/image.c index 74f5d60299..63ccbcd537 100644 --- a/src_c/image.c +++ b/src_c/image.c @@ -454,17 +454,10 @@ tobytes_surf_32bpp(SDL_Surface *surf, SDL_PixelFormat *format_details, { int w, h; -#if SDL_VERSION_ATLEAST(3, 0, 0) - Uint32 Rloss = format_details->Rbits; - Uint32 Gloss = format_details->Gbits; - Uint32 Bloss = format_details->Bbits; - Uint32 Aloss = format_details->Abits; -#else - Uint32 Rloss = format_details->Rloss; - Uint32 Gloss = format_details->Gloss; - Uint32 Bloss = format_details->Bloss; - Uint32 Aloss = format_details->Aloss; -#endif + Uint32 Rloss = PG_FORMAT_R_LOSS(format_details); + Uint32 Gloss = PG_FORMAT_G_LOSS(format_details); + Uint32 Bloss = PG_FORMAT_B_LOSS(format_details); + Uint32 Aloss = PG_FORMAT_A_LOSS(format_details); Uint32 Rmask = format_details->Rmask; Uint32 Gmask = format_details->Gmask; Uint32 Bmask = format_details->Bmask; @@ -565,19 +558,15 @@ image_tobytes(PyObject *self, PyObject *arg, PyObject *kwarg) if (!format_details) { return RAISE(pgExc_SDLError, SDL_GetError()); } - SDL_Palette *surf_palette = SDL_GetSurfacePalette(surf); - Rloss = format_details->Rbits; - Gloss = format_details->Gbits; - Bloss = format_details->Bbits; - Aloss = format_details->Abits; + SDL_Palette *surf_palette = PG_GetSurfacePalette(surf); #else SDL_PixelFormat *format_details = surf->format; SDL_Palette *surf_palette = surf->format->palette; - Rloss = format_details->Rloss; - Gloss = format_details->Gloss; - Bloss = format_details->Bloss; - Aloss = format_details->Aloss; #endif + Rloss = PG_FORMAT_R_LOSS(format_details); + Gloss = PG_FORMAT_G_LOSS(format_details); + Bloss = PG_FORMAT_B_LOSS(format_details); + Aloss = PG_FORMAT_A_LOSS(format_details); Rmask = format_details->Rmask; Gmask = format_details->Gmask; Bmask = format_details->Bmask; @@ -1722,7 +1711,7 @@ SaveTGA_RW(SDL_Surface *surface, SDL_RWops *out, int rle) } SDL_PixelFormat output_format; - SDL_Palette *surf_palette = SDL_GetSurfacePalette(surface); + SDL_Palette *surf_palette = PG_GetSurfacePalette(surface); #else SDL_PixelFormat *surf_format = surface->format; SDL_Palette *surf_palette = surface->format->palette; diff --git a/src_c/scrap.c b/src_c/scrap.c index 43fd96b915..8f1d2c8fd4 100644 --- a/src_c/scrap.c +++ b/src_c/scrap.c @@ -441,7 +441,11 @@ _scrap_put_text(PyObject *self, PyObject *args) return NULL; } +#if SDL_VERSION_ATLEAST(3, 0, 0) + if (!SDL_SetClipboardText(text)) { +#else if (SDL_SetClipboardText(text)) { +#endif return RAISE(pgExc_SDLError, SDL_GetError()); } diff --git a/src_c/scrap_sdl2.c b/src_c/scrap_sdl2.c index 754edaf1bf..fe75a75213 100644 --- a/src_c/scrap_sdl2.c +++ b/src_c/scrap_sdl2.c @@ -109,7 +109,11 @@ pygame_scrap_put(char *type, Py_ssize_t srclen, char *src) if (strcmp(type, pygame_scrap_plaintext_type) == 0 || strcmp(type, pygame_scrap_utf8text_type) == 0) { +#if SDL_VERSION_ATLEAST(3, 0, 0) + if (SDL_SetClipboardText(src)) { +#else if (SDL_SetClipboardText(src) == 0) { +#endif return 1; } } diff --git a/src_c/transform.c b/src_c/transform.c index 6c9a563c5e..bd09e52375 100644 --- a/src_c/transform.c +++ b/src_c/transform.c @@ -3737,7 +3737,7 @@ surf_average_color(PyObject *self, PyObject *args, PyObject *kwargs) Uint8 r, g, b, a; int x, y, w, h; static char *keywords[] = {"surface", "rect", "consider_alpha", NULL}; - SDL_bool consider_alpha = SDL_FALSE; + int consider_alpha = SDL_FALSE; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|Op", keywords, &pgSurface_Type, &surfobj, &rectobj, @@ -4051,7 +4051,7 @@ surf_box_blur(PyObject *self, PyObject *args, PyObject *kwargs) pgSurfaceObject *dst_surf_obj = NULL; pgSurfaceObject *src_surf_obj; SDL_Surface *new_surf = NULL; - SDL_bool repeat_edge_pixels = SDL_TRUE; + int repeat_edge_pixels = SDL_TRUE; int radius; @@ -4084,7 +4084,7 @@ surf_gaussian_blur(PyObject *self, PyObject *args, PyObject *kwargs) pgSurfaceObject *dst_surf_obj = NULL; pgSurfaceObject *src_surf_obj; SDL_Surface *new_surf = NULL; - SDL_bool repeat_edge_pixels = SDL_TRUE; + int repeat_edge_pixels = SDL_TRUE; int radius; diff --git a/src_py/_debug.py b/src_py/_debug.py index d3d9ee5f5b..a39f599bc4 100644 --- a/src_py/_debug.py +++ b/src_py/_debug.py @@ -63,9 +63,9 @@ def _get_platform_info(): Internal helper to get platform information """ cpu_inst_dict = get_cpu_instruction_sets() - sse2 = 'Yes' if cpu_inst_dict['SSE2'] else 'No' - avx2 = 'Yes' if cpu_inst_dict['AVX2'] else 'No' - neon = 'Yes' if cpu_inst_dict['NEON'] else 'No' + sse2 = "Yes" if cpu_inst_dict["SSE2"] else "No" + avx2 = "Yes" if cpu_inst_dict["AVX2"] else "No" + neon = "Yes" if cpu_inst_dict["NEON"] else "No" ret = f"Platform:\t\t{platform.platform()}\n" ret += f"System:\t\t\t{platform.system()}\n" ret += f"System Version:\t\t{platform.version()}\n" @@ -106,18 +106,17 @@ def default_return(linked=True): get_driver as get_display_driver, get_init as display_init, ) - from pygame.mixer import ( - get_driver as get_mixer_driver, - get_init as mixer_init, - ) + + debug_str, *mixer = attempt_import("pygame.mixer", "get_driver", debug_str) + get_mixer_driver = mixer[1] if mixer[0] else lambda: None + + debug_str, *mixer = attempt_import("pygame.mixer", "get_init", debug_str) + mixer_init = mixer[1] if mixer[0] else lambda: False debug_str, *mixer = attempt_import( "pygame.mixer", "get_sdl_mixer_version", debug_str ) - if not mixer[0]: - get_sdl_mixer_version = default_return - else: - get_sdl_mixer_version = mixer[1] + get_sdl_mixer_version = mixer[1] if mixer[0] else default_return debug_str, *font = attempt_import("pygame.font", "get_sdl_ttf_version", debug_str) if not font[0]: