Skip to content

Commit 741db24

Browse files
committed
Restrict set_alpha RLE hack to SDL2
We'll figure out SDL3 relevance later, right now it's just important to get Surface compiling.
1 parent 4532a65 commit 741db24

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src_c/surface.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,8 +1497,6 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
14971497
PyObject *alpha_obj = NULL, *intobj = NULL;
14981498
Uint8 alpha;
14991499
int result, alphaval = 255;
1500-
SDL_Rect sdlrect;
1501-
SDL_Surface *surface;
15021500

15031501
if (!PyArg_ParseTuple(args, "|Oi", &alpha_obj, &flags)) {
15041502
return NULL;
@@ -1548,24 +1546,24 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
15481546
SDL_SetSurfaceRLE(surf, (flags & PGS_RLEACCEL) ? SDL_TRUE : SDL_FALSE);
15491547

15501548
/* HACK HACK HACK */
1551-
#if SDL_VERSION_ATLEAST(3, 0, 0)
1552-
if (SDL_SurfaceHasRLE(surf) && (!(flags & PGS_RLEACCEL)))
1553-
#else
1554-
if ((surf->flags & SDL_RLEACCEL) && (!(flags & PGS_RLEACCEL)))
1555-
#endif
1556-
{
1549+
// TODO: SDL3: figure out how to port this or if it's relevant to SDL3.
1550+
#if !SDL_VERSION_ATLEAST(3, 0, 0)
1551+
if ((surf->flags & SDL_RLEACCEL) && (!(flags & PGS_RLEACCEL))) {
15571552
/* hack to strip SDL_RLEACCEL flag off surface immediately when
15581553
it is not requested */
1554+
SDL_Rect sdlrect;
15591555
sdlrect.x = 0;
15601556
sdlrect.y = 0;
15611557
sdlrect.h = 0;
15621558
sdlrect.w = 0;
15631559

1564-
surface = PG_CreateSurface(1, 1, PG_SURF_FORMATENUM(surf));
1560+
SDL_Surface *surface =
1561+
PG_CreateSurface(1, 1, PG_SURF_FORMATENUM(surf));
15651562

15661563
SDL_LowerBlit(surf, &sdlrect, surface, &sdlrect);
15671564
SDL_FreeSurface(surface);
15681565
}
1566+
#endif
15691567
/* HACK HACK HACK */
15701568
if (result == 0) {
15711569
result = !PG_SetSurfaceAlphaMod(surf, alpha);

0 commit comments

Comments
 (0)