SDL_MUSTLOCK() returns true once a surface has the RLE flag set

This more closely matches the mental model of people using SDL, and locking a surface that isn't RLE encoded doesn't cause any issues.

Fixes https://github.com/libsdl-org/SDL/issues/5594
This commit is contained in:
Sam Lantinga
2024-07-17 14:03:53 -07:00
parent de6595bda6
commit eefcb62588
2 changed files with 3 additions and 8 deletions

View File

@@ -46,7 +46,7 @@ SDL_bool SDL_SurfaceValid(SDL_Surface *surface)
void SDL_UpdateSurfaceLockFlag(SDL_Surface *surface)
{
if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
if (SDL_SurfaceHasRLE(surface)) {
surface->flags |= SDL_SURFACE_LOCK_NEEDED;
} else {
surface->flags &= ~SDL_SURFACE_LOCK_NEEDED;
@@ -460,6 +460,7 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, SDL_bool enabled)
if (surface->internal->map.info.flags != flags) {
SDL_InvalidateMap(&surface->internal->map);
}
SDL_UpdateSurfaceLockFlag(surface);
return 0;
}
@@ -1250,7 +1251,6 @@ int SDL_LockSurface(SDL_Surface *surface)
if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
SDL_UnRLESurface(surface, SDL_TRUE);
surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL; /* save accel'd state */
SDL_UpdateSurfaceLockFlag(surface);
}
#endif
}