Skip to content

Commit 2901dfa

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 f844ee7 commit 2901dfa

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
@@ -1496,8 +1496,6 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
14961496
PyObject *alpha_obj = NULL, *intobj = NULL;
14971497
Uint8 alpha;
14981498
int alphaval = 255;
1499-
SDL_Rect sdlrect;
1500-
SDL_Surface *surface;
15011499

15021500
if (!PyArg_ParseTuple(args, "|Oi", &alpha_obj, &flags)) {
15031501
return NULL;
@@ -1546,24 +1544,24 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
15461544
bool success =
15471545
PG_SetSurfaceRLE(surf, (flags & PGS_RLEACCEL) ? SDL_TRUE : SDL_FALSE);
15481546
/* HACK HACK HACK */
1549-
#if SDL_VERSION_ATLEAST(3, 0, 0)
1550-
if (SDL_SurfaceHasRLE(surf) && (!(flags & PGS_RLEACCEL)))
1551-
#else
1552-
if ((surf->flags & SDL_RLEACCEL) && (!(flags & PGS_RLEACCEL)))
1553-
#endif
1554-
{
1547+
// TODO: SDL3: figure out how to port this or if it's relevant to SDL3.
1548+
#if !SDL_VERSION_ATLEAST(3, 0, 0)
1549+
if ((surf->flags & SDL_RLEACCEL) && (!(flags & PGS_RLEACCEL))) {
15551550
/* hack to strip SDL_RLEACCEL flag off surface immediately when
15561551
it is not requested */
1552+
SDL_Rect sdlrect;
15571553
sdlrect.x = 0;
15581554
sdlrect.y = 0;
15591555
sdlrect.h = 0;
15601556
sdlrect.w = 0;
15611557

1562-
surface = PG_CreateSurface(1, 1, PG_SURF_FORMATENUM(surf));
1558+
SDL_Surface *surface =
1559+
PG_CreateSurface(1, 1, PG_SURF_FORMATENUM(surf));
15631560

15641561
SDL_LowerBlit(surf, &sdlrect, surface, &sdlrect);
15651562
SDL_FreeSurface(surface);
15661563
}
1564+
#endif
15671565
/* HACK HACK HACK */
15681566
if (success) {
15691567
success = PG_SetSurfaceAlphaMod(surf, alpha);

0 commit comments

Comments
 (0)