libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
194 stars 40 forks source link

Allocate video surface object statically as a global #306

Closed smcv closed 1 year ago

smcv commented 1 year ago

In #305, we have trouble with libsdl-perl making assumptions about the video surface never being freed or reallocated, and it being a no-op to "free" the video surface.

There is nothing that says a SDL 1.2 surface must always wrap the same SDL 2 surface, so we can maybe accommodate those assumptions by having the video surface be a special-cased global pointer that is never freed, and only reallocate its contents?

This seems to work with libsdl-perl's core_video.t test, but I haven't tested it extensively; consider it a proof-of-concept for now.

smcv commented 1 year ago

@slouken, @icculus: I think this is ready for at least a preliminary "is this a good direction?" review, but it isn't sufficiently tested to land it yet.

slouken commented 1 year ago

This seems like a good direction to me.

smcv commented 1 year ago

Rebased on main and fixed a missing NULL check. Briefly tested with:

and seems to work as intended.

smcv commented 1 year ago

I also contributed a fix for the incorrect free (PerlGameDev/SDL#306) which was applied to Debian's libsdl-perl package, but I haven't seen any sign of it being reviewed upstream. I also accidentally found PerlGameDev/SDL#307 while testing that change, and it hasn't had any response either, so PerlGameDev/SDL might be relatively dead.

slouken commented 1 year ago

Okay, well let's merge this then.

Thanks!